声明Provider
代码语言:javascript复制<?php
namespace 命名空间;
use IlluminateSupportServiceProvider;
use MonologFormatterLineFormatter;
use MonologHandlerRotatingFileHandler;
class LogServiceProvider extends ServiceProvider
{
/**
* Configure logging on boot.
*
* @return void
*/
public function boot()
{
$maxFiles = 0;
$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.
}
}
注册
在 bootstrapapp.php
中添加
$app->register(命名空间ProvidersLogServiceProvider::class);
打赏赞微海报分享