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);
});
Try this:
Log::useFiles('path/to/file.log');
Log::info('Info');
you can also refer this laravel link https://laravel.com/api/5.5/Illuminate/Log/Writer.html
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.