Most of my app logging is done at debug level because in sf 1.4 it’s not used by symfony itself, and that makes it easy to see just the messages I’m interested in using something like:
tail -f log/frontend_dev.php | grep "\[debug\]"
This is great in the dev environment while I’m sat there watching it scroll past, but I now want to log only these debug messages in the production environment.
If I set the log level for the production log to debug, then obviously I’ll get everything down to and including the debug level, which is far too much data.
Is it possible to write a logger that will just record [debug] messages and nothing else?
Of course it is possible – you can extend
sfFileLoggerand overridelog($message, $priority)function (whichsfFileLoggerinherits fromsfLoggerclass).Now you have to configure logging in your app to use your new logger class, configuration is located in
app/<your app>/config/factories.yml:This logger will save only messages logged with the same priority (and only the same, not the same or higher) as configured in
factories.yml.