zoukankan      html  css  js  c++  java
  • YII2 自定义日志路径

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


    配置:
    /config/web.php
      components->log
     默认配置:
    'log' => [
                'traceLevel' => YII_DEBUG ? 3 : 0,
                'targets' => [
                    [
                        'class' => 'yiilogFileTarget',
                        'levels' => ['error', 'warning'],
                    ],
                ],
            ],

    现修改配置如下:

    'log' => [
                'traceLevel' => YII_DEBUG ? 3 : 0,
                'targets' => [
                    [
                        'class' => 'yiilogFileTarget',
                        'levels' => ['error', 'warning','info','trace'],
                    ],
                    [
                        'class' => 'yiilogFileTarget',
                        '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,记录操作提示");

    输出自定义目录日志

           // 日志文件在输出目录  @app/runtime/logs/Mylog/requests.log
            Yii::info("info .... ","rhythmk");
  • 相关阅读:
    HyperV创建NAT网络
    Win10
    ConEmu
    ffmpeg的centos、msys2、msvc编译
    7z压缩gopath的src的批处理
    VS2015自带v120的Platform Toolset
    Putty配置
    第一章:HTML5的基础
    java的错题整理
    第十四章:类的带参方法
  • 原文地址:https://www.cnblogs.com/sandea/p/5616356.html
Copyright © 2011-2022 走看看