log4j-core 和 jboss 日志管理器之间的 Quarkus 日志记录冲突
我在 Quarkus 上运行的一些微服务的日志记录信息时遇到问题。一些项目在 build.gradle 中有以下设置:
实现'org.apache.logging.log4j:log4j-core'runtimeOnly'org.jboss.logmanager
:log4j2-jboss-logmanager'
我们的代码使用apache log4j LogManager和Logger记录信息。当我们在 gradle 文件中拥有具有这两个依赖项的项目时,日志设置不起作用,因此,无论 application.properties 中的任何设置如何,都不会写入任何内容(除了错误的默认设置)。对于不依赖 log4j-core 的其他项目,日志记录工作得很好。
我的一位同事告诉我,当这两个库包含在项目中时,会发生一些重写,他建议使用 org.jboss.logging.Logger 代替 apache log4j LogManager。我没有尝试任何其他设置,但我确实在日志文件中看到了信息日志,因此它正在工作,尽管我必须更改一些代码以匹配 jboss Logger 对象上的方法签名。虽然我很高兴它能正常工作,但我希望避免在项目中以两种不同的方式编写逻辑(例如 - Logger 来自 apache log4j 中的 LogManager,而它仅来自 jboss 方法中的 Logger 类本身)
我试图理解什么造成这种冲突的原因以及是否有人有比我所做的更好的方法来使其发挥作用。请让我知道
提前感谢您的帮助!
此致 SG
I am having an issue with logging information for some of the microservices running on Quarkus. Some of the projects have the below settings in the build.gradle:
implementation 'org.apache.logging.log4j:log4j-core'
runtimeOnly 'org.jboss.logmanager:log4j2-jboss-logmanager'
Our code uses apache log4j LogManager and Logger to log information. When we have the projects with these 2 dependencies in the gradle file, the log settings don't work and as a result, nothing gets written (except for the default setting of error) irrespective of any settings in the application.properties. For the other projects where there is no dependency on log4j-core, the logging works perfectly fine.
What i was told by one of my colleagues is that there is some overriding happens when these 2 libraries are included in a project and he suggested using the org.jboss.logging.Logger in place of the apache log4j LogManager. I haven't tried any other settings but i do see the info logs now in the log file so it is working though i am having to change some code to match the method signatures on the jboss Logger object. While i am happy it's working, i would like to avoid having to code logic in 2 different ways across projects (example - Logger comes from LogManager in apache log4j whereas it just comes from Logger class itself in jboss approach)
I am trying to understand what is causing this conflict and why and also if anyone has any better way than what I did to make it work. Please let me know
Thanks in advance for your help!
Best Regards
SG
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论