o__荒年 2017-02-23 09:45:47 5685次浏览 1条评论 0 2 0

在main.php中配置如下

'log' => [
    'traceLevel' => YII_DEBUG ? 3 : 0,
    'targets' => [
        [
            'class' => 'yii\log\FileTarget',
            'levels' => ['error', 'warning'],

        ],
        [
            'class' => 'yii\log\FileTarget',
            'levels' => ['info'],
            'categories' => ['request'],
            'logFile' => '@app/runtime/Mylog/requests.log',
            'maxFileSize' => 1024 * 2,
            'maxLogFiles' => 20,
        ],
    ],
],

然后代码就可以Yii:info('xxx','request');

觉得很赞
  • 评论于 2017-03-27 16:28 举报

    详细的教程如下,
    'log' => [

    'traceLevel' => YII_DEBUG ? 3 : 0,
    'targets' => [
        [
            'class' => 'yii\log\FileTarget',
            'levels' => ['error', 'warning'],//这里说明配置的是那个,如error,warning,info,trace这些
    
        ],
        [
            'class' => 'yii\log\FileTarget',
            'levels' => ['info'],//这里说明配置的是那个,如error,warning,info,trace这些
            'categories' => ['request'],//这里说明的保存的文件名
            'logFile' => '@app/runtime/Mylog/requests.log',//这里说明的保存的文件名的路径
            'maxFileSize' => 1024 * 2,//这些一看就知道的就不说明了
            'maxLogFiles' => 20,
        ],
    ],
    

    ],

您需要登录后才可以评论。登录 | 立即注册