Yii2.0自定义日志文件写日志

示例如下:

[php]

use yii\log\FileTarget;

$time = microtime(true);
$log = new FileTarget();
$log->logFile = Yii::$app->getRuntimePath() . ‘/logs/123.log’;  //文件名自定义
$log->messages[] = [‘test’,1,’application’,$time];
$log->export();

[/php]

$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)
*/

 

您可能还喜欢...

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注