Yii2.0 Chinese development wizard-custom log file write log, yii2.0 log file. Yii2.0 Chinese development wizard-custom log file write log, yii2.0 log file header introduces log class useyiilogFileTarget; $ timemicrotime (true); $ lognewFileTarget (); $ log-Yii2.0 Chinese development wizard-custom log file write log, yii2.0 log file
Introduce the log class to the header
Use yii \ log \ FileTarget;
$ Time = microtime (true );
$ Log = new FileTarget ();
$ Log-> logFile = Yii: $ app-> getRuntimePath (). '/logs/zhidemy.com. log'; // custom file name
$ Log-> messages [] = ['test', 1, 'application', $ time];
$ Log-> export ();
In this way, the class description of $ log-> message can be written first.
/*
* [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)
*/
You can pass the parameters according to the information. Remember the important points
$ Log-> messages [] do not forget to add []
For details, refer to the Target class.
Use yii \ log \ FileTarget; $ time = microtime (true); $ log = new FileTarget (); $ log -...