I’m new to the Yii2 framework, coming from CI (and new to Composer), it has a steep learning curve.
I was wondering how you replace Yii2 logging with Log4PHP. I have it installed with Composer, but I don’t know how to use it in Yii2/replace Yii2 logging.
The issue is not the log targets. Also the last update for Log4PHP is of little consequence when something runs very well and doesn’t need to be updated.
Log4PHP is more advance, it has appenders and loggers. From what I’ve looked at Yii2 does not. So I can’t create an appender and tell the logger to use it, or what the log level is for that logger. The log level is applied globally. If I set file logging to use error and info anything that has logging of error and info will be logged. Which is fine and all, but in our current project we have some loggers that are at ERROR and some that are at DEBUG, but in both cases they have info methods being called that’s not logged, because we don’t need it most of the time. However, the info logging is left in there so that ERROR can be bumped up to get those info logs if necessary.
Moreover, Yii2 creates a new file at 10MB. I don’t see an option to change the file size, compress the rollover files, change log formatting (or add mapped diagnostic constant), or even change the file name. Though I think the last one would be something you guys take into consideration because it’s obvious, I just don’t see it. Yii2’s logging is basically a slimmed down version of Log4PHP from what I can tell.
I do like that Yii2 stays relatively fast as the file size expands. Something CI’s default logging doesn’t do, the larger the file size the slower CI gets because it does a seek() to the end of the file.
Overall I give Yii2 a 4 out of 5, it just has a steep learning curve and not everything is intuitive or clear.