From 3d3ed6ab03e9dcdb63571a3d82e00ea5699a6acf Mon Sep 17 00:00:00 2001 From: snipe Date: Tue, 24 Jul 2018 20:48:16 -0700 Subject: [PATCH] Logging updates for 5.6 --- app/Providers/AppServiceProvider.php | 5 -- config/app.php | 48 ----------------- config/logging.php | 81 ++++++++++++++++++++++++++++ 3 files changed, 81 insertions(+), 53 deletions(-) create mode 100644 config/logging.php diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index fdceca359..90f4c15fc 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -52,15 +52,10 @@ class AppServiceProvider extends ServiceProvider */ public function register() { - $monolog = Log::getMonolog(); - $log_level = config('app.log_level'); if (($this->app->environment('production')) && (config('services.rollbar.access_token'))){ $this->app->register(\Rollbar\Laravel\RollbarServiceProvider::class); } - foreach ($monolog->getHandlers() as $handler) { - $handler->setLevel($log_level); - } } } diff --git a/config/app.php b/config/app.php index 1ff1661d7..3d66ad6a6 100755 --- a/config/app.php +++ b/config/app.php @@ -117,54 +117,6 @@ return [ 'cipher' => env('APP_CIPHER', 'AES-256-CBC'), - /* - |-------------------------------------------------------------------------- - | Logging Configuration - |-------------------------------------------------------------------------- - | - | Here you may configure the log settings for your application. Out of - | the box, Laravel uses the Monolog PHP logging library. This gives - | you a variety of powerful log handlers / formatters to utilize. - | - | Available Settings: "single", "daily", "syslog", "errorlog" - | - */ - - 'log' => env('APP_LOG', 'single'), - - /* - |-------------------------------------------------------------------------- - | Logging Max Files - |-------------------------------------------------------------------------- - | - | When using the daily log mode, Laravel will only retain 5 - | days of log files by default. - | - | To change this, set the APP_LOG_MAX_FILES option in your .env. - | - */ - - 'log_max_files' => env('APP_LOG_MAX_FILES', 5), - - /* - |-------------------------------------------------------------------------- - | Logging Detail - |-------------------------------------------------------------------------- - | - | By default, Laravel writes all log levels to storage. However, in your - | production environment, you may wish to configure the minimum severity that - | should be logged by editing your APP_LOG_LEVEL env config. - | - | Laravel will log all levels greater than or equal to the specified severity. - | For example, a default log_level of error will log error, critical, alert, - | and emergency messages. - | - | APP_LOG_LEVEL options are: - | "debug", "info", "notice", "warning", "error", "critical", "alert", "emergency" - | - */ - - 'log_level' => env('APP_LOG_LEVEL', 'error'), /* diff --git a/config/logging.php b/config/logging.php new file mode 100644 index 000000000..c3b0a1955 --- /dev/null +++ b/config/logging.php @@ -0,0 +1,81 @@ + env('LOG_CHANNEL', 'stack'), + + /* + |-------------------------------------------------------------------------- + | Log Channels + |-------------------------------------------------------------------------- + | + | Here you may configure the log channels for your application. Out of + | the box, Laravel uses the Monolog PHP logging library. This gives + | you a variety of powerful log handlers / formatters to utilize. + | + | Available Drivers: "single", "daily", "slack", "syslog", + | "errorlog", "monolog", + | "custom", "stack" + | + */ + + 'channels' => [ + 'stack' => [ + 'driver' => 'stack', + 'channels' => ['single'], + ], + + 'single' => [ + 'driver' => 'single', + 'path' => storage_path('logs/laravel.log'), + 'level' => 'debug', + ], + + 'daily' => [ + 'driver' => 'daily', + 'path' => storage_path('logs/laravel.log'), + 'level' => 'debug', + 'days' => env('APP_LOG_MAX_FILES', 5), + ], + + 'slack' => [ + 'driver' => 'slack', + 'url' => env('LOG_SLACK_WEBHOOK_URL'), + 'username' => 'Laravel Log', + 'emoji' => ':boom:', + 'level' => 'critical', + ], + + 'stderr' => [ + 'driver' => 'monolog', + 'handler' => StreamHandler::class, + 'with' => [ + 'stream' => 'php://stderr', + ], + ], + + 'syslog' => [ + 'driver' => 'syslog', + 'level' => env('APP_LOG_LEVEL', 'error'), + ], + + 'errorlog' => [ + 'driver' => 'errorlog', + 'level' => env('APP_LOG_LEVEL', 'error'), + ], + ], + +];