lundi 24 septembre 2018

Laravel : How to Log INFO/ERROR to separate file

How to separate error and info into different files in laravel5.5?
This is my code in bootstrap/app.php
But errors will appear in both error.log and lumen.log

$app->configureMonologUsing(function (\Monolog\Logger $monolog) use ($app) {
    $handlerError = new \Monolog\Handler\RotatingFileHandler(storage_path('logs/error.log'), $app->make('config')->get('app.log_max_files', 5), \Monolog\Logger::ERROR);
    $handlerInfo = new \Monolog\Handler\RotatingFileHandler(storage_path('logs/lumen.log'), $app->make('config')->get('app.log_max_files', 5), \Monolog\Logger::INFO);
    $monolog->pushHandler($handlerError);
    $monolog->pushHandler($handlerInfo);
});



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire