Seldaek / monolog

Sends your logs to files, sockets, inboxes, databases and various web services

Home Page:https://seldaek.github.io/monolog/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Help with my three questions

AC-Lover opened this issue · comments

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

  1. I want when $log->error(); I used it, so that the log is only saved in Error.log, what should I do?
  2. And that I want it to be printed in the terminal at the same time
  3. How to clear the log files? Or limit it and delete it automatically
  1. Use a FilterHandler to select a single level, and put the StreamHandler inside it
  2. Add another StreamHandler with php://stdout as stream
  3. The best is to use logrotate, but we do have RotatingFileHandler as well for basic purposes

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 :)

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).