如何集中日志配置,并仅使用 log4j.properties?
我想使用 log4j.properties
在我的应用程序中配置日志记录,并指示(以某种方式)所有第三方包/模块通过此配置进行日志记录。现在它们的日志记录不同,而且一团糟:OpenEJB、Hibernate、Apache HttpClient、Jersey 等。我该怎么做?我只想使用 log4j
。
I would like to configure logging in my application with log4j.properties
and instruct (somehow) all third-party packages/modules to log through this configuration. Now they log differently and it's a mess: OpenEJB, Hibernate, Apache HttpClient, Jersey, etc. How can I do this? I want to work with log4j
only.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用可以将各种日志框架重定向到
log4j
的框架:slf4j。有关概述,请参阅“桥接旧版 API”。
[编辑] slf4j 的 Maven
pom.xml
:Use a framework which can redirect all kinds of logging frameworks to
log4j
: slf4j.See "Bridging legacy APIs" for an overview.
[Edit] Maven
pom.xml
for slf4j: