Im looking for a log system which works with different verbosity levels and flushes to file or console immediately. I work with yii2. They Yii2 Log is good and has info, debug, warn, error levels. But I cannot get it to work realtime to flush on screen. I have tried with flushInterval as 1 or even 0 but does not work. yii2 log methods have application param, so I can filter what parts get logged, in case some module is buggy. Many of my cli apps never die, so logs come up only after many hours like a flood.
Maybe there is a totally diff composer package which does same thing.
Thanks.
Logs are grouped on two levels:
Dispatcher::$flushInterval.Target::$exportInterval.So in addition to
flushInterval, you need to also configureexportIntervalfor given target, if you want to export every single log one by one:But you may get better performance by calling
Yii::$app->log->flush(true)after finishing every task on long-running process. So if you're processing 1k models in console command, you runYii::$app->log->flush(true)after each model - it should greatly reduce logger overhead and still be pretty close to "real-time" (as long as processing one model does not take much time).