码迷,mamicode.com
首页 > 其他好文 > 详细

Yii日志记录Logging

时间:2015-11-23 11:30:52      阅读:110      评论:0      收藏:0      [点我收藏+]

标签:

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‘);

在config,main.php配置

 components->log
默认配置:
‘log‘=> [
            ‘traceLevel‘ => YII_DEBUG ? 3 : 0,
            ‘targets‘ => [
                [
                    ‘class‘ => ‘yii\log\FileTarget‘,
                    ‘levels‘ => [‘error‘, ‘warning‘],
                ],
            ],
        ],

修改

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‘ => 1024 * 2,
                    ‘maxLogFiles‘ => 20,
                ],
            ],
        ],

输出日志:

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

 

Yii日志记录Logging

标签:

原文地址:http://www.cnblogs.com/baby123/p/4987552.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!