laravel log改为时间格式

1 providers新建文件

LogRotateServiceProvider.php
<?php

namespace App\Providers;

use Monolog\Formatter\LineFormatter;
use Illuminate\Support\ServiceProvider;
use Monolog\Handler\RotatingFileHandler; class LogRotateServiceProvider extends ServiceProvider
{ /**
* Perform post-registration booting of services.
*
* @return void
*/
public function boot()
{
$file = env('LOG_FILE_PATH') ? env('LOG_FILE_PATH') : storage_path('logs/laravel.log');
$output = "[%datetime%][%channel%][Level:%level_name%][Message:%message% %context% %extra%]\n";
$handlers[] = (new RotatingFileHandler(env('LOG_PATH' , $file) , env('LOG_MAXFILE' , 5)))
->setFormatter(new LineFormatter($output , null , true , true));
$this->app['log']->setHandlers($handlers);
}
}

  app/bootstrap 添加代码

$app->register(App\Providers\LogRotateServiceProvider::class);
上一篇:python笔记:#004#注释


下一篇:jQuery中设置form表单中action值与js有什么不同。。。。