、Yii::getLogger()->log($message, $level, $category = 'application')
、Yii::trace($message, $category = 'application');
、Yii::error($message, $category = 'application');
、Yii::warning($message, $category = 'application');
、Yii::info($message, $category = 'application');
在config,main.php配置
components->log
默认配置:
'log'=> [
'traceLevel' => YII_DEBUG ? : ,
'targets' => [
[
'class' => 'yii\log\FileTarget',
'levels' => ['error', 'warning'],
],
],
],
修改
'log' => [
'traceLevel'=> YII_DEBUG ? : ,
'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' => * ,
'maxLogFiles' => ,
],
],
],
输出日志:
Yii::getLogger()->log("开始写自定义日志",Logger::LEVEL_ERROR); Yii::trace("trace,开发调试时候记录"); Yii::error("error,错误日志"); Yii::warning("warning,警告信息"); Yii::info("info,记录操作提示");
Yii::info("info .... ","rhythmk");//输出自定义目录日志,@app/runtime/logs/Mylog/requests.log