laravel5.5自定义日志使用
在任意位置调用自定义日志前写入即可
$monolog = Log::getMonolog();
$monolog->popHandler();
Log::useFiles(storage_path('logs/test/test.log'));
Log::info('test');
laravel5.7自定义日志使用
在config文件夹下找到logging中找到
'channels' => [
......
'adminlog' => [
'driver' => 'daily',
'path' => storage_path('logs/adminlog/adminlog.log'),
'level' => 'debug',
'days' => 14,
],
]
调用即可
Log::channel('adminlog')->info('adminlog ok');
php原生打印到指定日志文件
file_put_contents(storage_path('/logs/info.log'),print_r($res_purchaser, 1)."
",8);
//监听sql语句
Event::listen('illuminate.query', function($sql,$param) {
file_put_contents(storage_path('/logs/sql.log'),$sql.'['.print_r($param, 1).']'."
",8);
});
搞定,收工!!!