Help with my three questions
AC-Lover opened this issue · comments
AC-Lover commented
Monolog version 3.3.1
$log->pushHandler(new StreamHandler(__DIR__.'/Warning.log', Level::Warning));
$log->pushHandler(new StreamHandler(__DIR__.'/Error.log', Level::Error));
$log->pushHandler(new StreamHandler(__DIR__.'/Debug.log', Level::Debug));
$log->pushHandler(new StreamHandler(__DIR__.'/Info.log', Level::Info));
Hello
- I want when
$log->error();
I used it, so that the log is only saved in Error.log, what should I do? - And that I want it to be printed in the terminal at the same time
- How to clear the log files? Or limit it and delete it automatically
Jordi Boggiano commented
- Use a FilterHandler to select a single level, and put the StreamHandler inside it
- Add another StreamHandler with php://stdout as stream
- The best is to use
logrotate
, but we do have RotatingFileHandler as well for basic purposes
rainerzufall081572 commented
Hello @Seldaek , what exactly is meant by "use logrotate" in this context? is logrotate another product/tool/library that can be used with monolog? or some part/configuration/setting of monolog? thank you :)
Jordi Boggiano commented
Here is more info about logrotate https://docs.rackspace.com/support/how-to/understanding-logrotate-utility/ - it's a log rotating utility which is present by default on most linux systems (AFAIK).