宣告Provider
<?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);
本作品採用《CC 協議》,轉載必須註明作者和本文連結