Yii2.0 Chinese development wizard-custom log file write log, yii2.0 Log File

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.