Custom logging to only show debug info if the app is in debug mode

or if the user has overridden the APP_LOG_LEVEL in their env
This commit is contained in:
snipe 2016-11-30 20:38:46 -08:00
parent b614470b21
commit 820d37cabb
2 changed files with 17 additions and 1 deletions

View file

@ -4,6 +4,7 @@ namespace App\Providers;
use Validator;
use Illuminate\Support\ServiceProvider;
use DB;
use Log;
/**
@ -78,6 +79,20 @@ class AppServiceProvider extends ServiceProvider
*/
public function register()
{
//
$monolog = Log::getMonolog();
if (config('app.debug')) {
$log_level = 'debug';
} else {
if (config('log-level')) {
$log_level = config('log-level');
} else {
$log_level = 'error';
}
}
foreach($monolog->getHandlers() as $handler) {
$handler->setLevel($log_level);
}
}
}

View file

@ -109,6 +109,7 @@ return [
*/
'log' => env('APP_LOG', 'single'),
'log-level' => env('APP_LOG_LEVEL', 'error'),
/*