Home >Backend Development >PHP Tutorial >Yii2.0 Chinese Development Wizard - Custom log file writing log, yii2.0 log file_PHP tutorial

Yii2.0 Chinese Development Wizard - Custom log file writing log, yii2.0 log file_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 09:45:071127browse

Yii2.0 Chinese Development Wizard - Customize log files to write logs, yii2.0 log files

Introduce the log class in the header
use yiilogFileTarget;


$time = microtime(true);
$log = new FileTarget();
$log->logFile = Yii::$app->getRuntimePath() . '/logs /zhidemy.com.log'; //Customized file name
$log->messages[] = ['test',1,'application',$time];
$log->export ();


This can basically be written. First, take a look at the class description information of $log->message
/*
* [0] => message ( mixed, can be a string or some complex data, such as an exception object)
* [1] => level (integer)
* [2] => category (string)
* [ 3] => timestamp (float, obtained by microtime(true))
* [4] => traces (array, debug backtrace, contains the application code call stacks)
*/

Just pass the parameters according to this information. Finally, remember the important point
$log->messages[] Don’t forget to add []
For details, please view the Target class

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1043456.htmlTechArticleYii2.0 Chinese Development Wizard - Customize the log file to write the log, and introduce the log into the header of the yii2.0 log file Class use yiilogFileTarget; $time = microtime(true); $log = new FileTarget(); $log-...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn