仅将调试级别消息记录到 symfony 1.4 中的文件中
我的大部分应用程序日志记录都是在调试级别完成的,因为在 sf 1.4 中,symfony 本身不使用它,这使得我可以轻松查看我感兴趣的消息,例如:
tail -f log/frontend_dev.php | grep "\[debug\]"
这在开发环境中很棒,而我'我坐在那里看着它滚动过去,但我现在只想在生产环境中记录这些调试消息。
如果我将生产日志的日志级别设置为要调试,那么显然我会将所有内容都降低到并包括调试级别,这是太多的数据。
是否可以编写一个仅记录[调试]消息而不记录其他内容的记录器?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当然这是可能的 - 您可以扩展
sfFileLogger
并覆盖log($message, $priority)
函数(sfFileLogger
继承自sfLogger
类)。现在,您必须在应用程序中配置日志记录以使用新的记录器类,配置位于
app//config/factories.yml
中:此记录器将仅保存使用与factories.yml中配置的优先级相同(并且仅相同,不相同或更高)。
Of course it is possible - you can extend
sfFileLogger
and overridelog($message, $priority)
function (whichsfFileLogger
inherits fromsfLogger
class).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
.