頭部引入log類use yii/log/FileTarget;
$time = microtime(true);$log = new FileTarget();$log->logFile = Yii::$app->getRuntimePath() . '/logs/zhidemy.com.log';//文件名自定義$log->messages[] = ['test',1,'application',$time];$log->export();這樣基本就能寫出來了,先看一下$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)*/傳遞參數按照這些信息進行傳遞就可以了。最后記住重要的一點$log->messages[] 別忘了加[]具體可查看Target類
新聞熱點
疑難解答