如何在 PlayFramework 项目中使用 logback
由于对项目的依赖性,我正在使用 Play!Framework 开发一个 Web 应用程序,我必须配置 logback 以防止它用 DEBUG 消息淹没我的输出。 但由于 log4j 是 Play!Framework 使用的默认日志库,我真的不知道如何让它考虑 logback.xml 配置文件。
最好的办法是让 Play!Framework 完全使用 logback/Slf4j 而不是 log4j。我怎么能这样做呢?
Because of dependencies on a project I am working on developing a web application using the Play!Framework, I have to configure logback to prevent it from flooding my output with DEBUG messages.
But as log4j is the default log library used by the Play!Framework, I don't really know how to make it consider a logback.xml configuration file.
The best would be to make the Play!Framework completely use logback/Slf4j instead of log4j. How could I do this ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
目前 play1 使用 log4j 或 juli (我不确定 juli 是否有效,但代码存在)。有功能请求,但不幸的是,如果您只有一个 Logger.class,则无法正确使用 logback。在本例中,%F 和来自 PatternLayout 所讨论的 此处。
更新:在从 Ceki 获得一些信息后,我现在知道了如何以干净的方式修复它。因此功能请求可以以干净的方式实现。
如果可能的话,一个想法是让 log4j 写入 logback。
此外,我正在考虑创建一个补丁来解决这个问题。因此,在这个问题得到解决并且我从核心团队收到一些信号表明他们接受在这样一个中心类中进行任何重构之前,我不想开始。
长话短说:目前,不破解框架是不可能的。
不过我不明白你的问题。什么是你想做而 log4j 做不到的?也许你可以在另一个问题中解释你的根本原因。
At the moment play1 use log4j or juli (I'm not sure if juli works, but the code exists). There is feature-request, but unfortunately you can't use logback correctly if you have a single Logger.class. In this case %F and all other uppercase chars from PatternLayout which is discussed here.
Update: After some information from Ceki, I have now the knowledge how it can fixed in a clean way. So the feature-request can implemented in a clean way.
An idea could be to let log4j write to logback, if it will possible.
Furthermore I'm thinking about creating a patch which solve this issue. So I don't want to start until this is fixed and I get some signals from the core-team that they accept any re-factoring at such a central class.
To make a long story short: At the moment it's impossible without hacking the framework.
However I don't understand your problem. What do you want to do that log4j can't? Perhaps you could explain your root cause in another question.