Logging updates for 5.6

This commit is contained in:
snipe 2018-07-24 20:48:16 -07:00
parent 14735057a8
commit 3d3ed6ab03
3 changed files with 81 additions and 53 deletions

View file

@ -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);
}
}
}

View file

@ -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'),
/*

81
config/logging.php Normal file
View file

@ -0,0 +1,81 @@
<?php
use Monolog\Handler\StreamHandler;
return [
/*
|--------------------------------------------------------------------------
| Default Log Channel
|--------------------------------------------------------------------------
|
| This option defines the default log channel that gets used when writing
| messages to the logs. The name specified in this option should match
| one of the channels defined in the "channels" configuration array.
|
*/
'default' => 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'),
],
],
];