The log write method provided by YII:
1, Yii::getlogger ()->log ($message, $level, $category = ' application ')
2, Yii::trace ($message, $category = ' application ');
3, Yii::error ($message, $category = ' application ');
4, Yii::warning ($message, $category = ' application ');
5, Yii::info ($message, $category = ' application ');
Configuration:
/config/web.php
Components->log
Default configuration:
'Log'= [ 'TraceLevel'= Yii_debug?3:0, 'Targets'= [ [ 'class'='Yii\log\filetarget', 'levels'= ['Error','Warning'], ], ], ],
The configuration is now modified as follows:
'Log'= [ 'TraceLevel'= Yii_debug?3:0, 'Targets'= [ [ 'class'='Yii\log\filetarget', 'levels'= ['Error','Warning','Info','Trace'], ], [ 'class'='Yii\log\filetarget', 'levels'= ['Info'], 'Categories'= ['RHYTHMK'], 'LogFile'='@app/runtime/logs/mylog/requests.log', 'MaxFileSize'=1024x768*2, 'Maxlogfiles'= -, ], ], ],
Output log:
Yii::getlogger ()->log ("Start writing custom Log", Logger::level_error);
Yii::trace ("Trace, logging when developing and debugging");
Yii::error ("error log");
Yii::warning ("Warning, warning message");
Yii::info ("info, record operation Tips");
Output Custom Directory Logs
The log file is in the output directory @app/runtime/logs/mylog/requests.log yii::info ("info .... "," RHYTHMK ");
YII2 a custom log path