Yii2 自訂日誌檔案寫入日誌
Aug 08, 2016 am 09:18 AM頭部引入log類別
use yiilogFileTarget;
$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類
以上就介紹了Yii2 自訂日誌檔案寫日誌,包括了方面的內容,希望對PHP教程有興趣的朋友有所幫助。

熱門文章

熱門文章

熱門文章標籤

記事本++7.3.1
好用且免費的程式碼編輯器

SublimeText3漢化版
中文版,非常好用

禪工作室 13.0.1
強大的PHP整合開發環境

Dreamweaver CS6
視覺化網頁開發工具

SublimeText3 Mac版
神級程式碼編輯軟體(SublimeText3)

SpringBoot之bootstrap和application的差別是什麼
