当前位置:网站首页>ThinkPHP 5 log management

ThinkPHP 5 log management

2022-06-25 04:49:00 Oglie's magic slippers~

ThinkPHP 5 Log management

In the configuration file, such as /application/config.php

    'log'                    => [
        //  Logging mode , built-in  file socket  Support extended 
        'type'  => 'File',
      // 'type' => 'test', // Close the log , If it is this configuration ,Log::write() Such methods are useless 
        //  Log save directory 
        'path'  => LOG_PATH,
        //  Logging level 
        'level' => [],// ['log', 'error', 'info', 'sql', 'notice', 'alert', 'debug'];// To be specific, see /thinkphp/library/think/Log.php Configuration of 
        'apart_level'   =>  ['sql'],// Configure a separate file , Normally we suggest that sql Statement in a separate file 
        'max_files'=>100,// Maximum number of saved logs , exceed tp Will clean up automatically 
        'close'=>false,// Whether to turn off log writing 
        'json'=>true,//json Format log on 
    ],
record() Logging to memory
save() Save the log information stored in memory ( Use the specified recording method ) write in , And clear the log in memory
write() Write a log message in real time , Will trigger save operation

Because the system will automatically call after the request Log::save Method , So usually , You just call Log::record Just record the log information .

Generate log path :\runtime\log
 Insert picture description here

原网站

版权声明
本文为[Oglie's magic slippers~]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202210533330953.html