2016-05-12 09:58:55 9007次浏览 3条回答 1 悬赏 10 金钱

如果我在main.php的LOG设置中,没有定义h1这个categories,以下语句能不能写入日志文件?
(使用方式:/usr/server/php/bin/php /var/test/yii/yii test/calculate-test >> /root/logs/week.log 2>&1)
Yii::info('hello','h1');

最佳答案

  • 撸sir 发布于 2016-05-16 14:36 举报

    `[

                    'class' => 'yii\log\FileTarget',
    
                    'levels' => ['info','error'],
    
                    'categories' => ['guangdian'],
                    'logVars'=>[],
                    'logFile' => '@app/runtime/logs/gd'.date('Ymd').'.log',
    
                    'maxFileSize' => 1024 * 5,
                    'maxLogFiles' => 150,
    
                ]`
    
    1 条回复
    回复于 2016-05-17 15:23 回复

    thank you! 已解决,添加了配置文件,自己没读懂文档!劳驾了!

  • 回答于 2016-05-12 22:00 举报

    分类可以随便命名的

    1 条回复
    回复于 2016-05-13 09:26 回复

    我使用
    Yii\BaseYii::info('current_time:' . date('Y-m-d H:i:s'),'Current_time');

    Yii::info('hello','h1');
    均无法生效,请问可能有什么原因会导致这样的结果?

  • 回答于 2016-05-13 10:13 举报

    你把info级别的错误记录日志没。。。

    3 条回复
    回复于 2016-05-13 10:23 回复

    不太明白...
    main.php中log数组该怎么写,我想在Linux运行时指定写入文件 如/root/test/test.log
    这么写么?

    'targets'=>[
        'class'=>'yii\log\FileTarget',
        'levels'=>['info']
    ]
    
    回复于 2016-05-13 11:20 回复

    。。自己研究吧。我只能说你的问题不是category的问题、category可以随便写的

    回复于 2016-05-17 15:23 回复

    thank you!

您需要登录后才可以回答。登录 | 立即注册
Trient
见习主管

Trient GZ

注册时间:2016-03-30
最后登录:2016-06-14
在线时长:6小时3分
  • 粉丝0
  • 金钱215
  • 威望0
  • 积分275

热门问题