简体   繁体   中英

How do I write separate log files for each Log level in Laravel 4?

My current logging setup creates a file for application messages and cli message. How would I get it to create a separate file for each of the different log levels (DEBUG, ERROR, etc...)?

My app/start/global.php config is like this:

$logFile = 'log-'.php_sapi_name().'.txt';

Log::useDailyFiles(storage_path().'/logs/'.$logFile);

App::error(function(Exception $exception, $code)
{
    Log::error($exception);
});

Use something like that:

$handler = new Monolog\Handler\RotatingFileHandler(storage_path().'/logs/info.log',0,Logger::INFO);
Log::getMonolog()->pushHandler($handler);

If you want it for errors use Logger::ERROR etc.

For Documentation of the __construct: https://github.com/Seldaek/monolog/blob/master/src/Monolog/Handler/RotatingFileHandler.php

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM