I'm trying to do something with monolog that I'm not sure it's possible. So I was thinking of a practical way to organize the log files.
First I thought to have 3 different files, INFO, WARNING and ERROR, but it would be difficult to search a specific date inside de file. So I decided to organize like this:
Logs
- |_ Info |_Year |_12-05-2016.log
- |_Warning |_Year |_12-05-2016.log
- |_Error |_Year |_12-05-2016.log
Here's what I decided to do
$infoStreamHandler = new \Monolog\Handler\RotatingFileHandler($settings['path_info'].'/info.log', Monolog\Logger::INFO);
$warningStreamHandler = new \Monolog\Handler\RotatingFileHandler($settings['path_warn'].'/warning.log', Monolog\Logger::WARNING);
$errorStreamHandler = new \Monolog\Handler\RotatingFileHandler($settings['path_error'].'/error.log', Monolog\Logger::ERROR);
$logger ->pushHandler($infoStreamHandler);
$logger->pushHandler($warningStreamHandler);
$logger->pushHandler($errorStreamHandler);
But this does not work as I expected. I tried first with StreamHandler
and it worked(but it was only creating one file for all dates), but as soon as I switched to RotatingFileHandler
it saved the same warning in all 3 files, instead of saving it in the warning log only.
Any thoughts ?
Thank you in advance.