配置lumen的log为daily模式
1.首先添加服务提供者类LogServiceProvider
<?php namespace App\Providers; use Illuminate\Support\ServiceProvider; use Monolog\Formatter\LineFormatter; use Monolog\Handler\RotatingFileHandler; class LogServiceProvider extends ServiceProvider { /** * Configure logging on boot. * * @return void */ public function boot() { $maxFiles = 5; $handlers[] = (new RotatingFileHandler(storage_path("logs/lumen.log"), $maxFiles)) ->setFormatter(new LineFormatter(null, null, true, true)); $this->app['log']->setHandlers($handlers); } /** * Register the log service. * * @return void */ public function register() { // Log binding already registered in vendor/laravel/lumen-framework/src/Application.php. } }
2.然后在bootstrap/app.php注册该服务提供者
$app->register(\App\Providers\LogServiceProvider::class);
posted on 2017-06-06 18:48 dongruiha 阅读(1163) 评论(0) 编辑 收藏 举报