简体   繁体   English

将 log4j2 日志重定向到 java.util.logging

[英]Redirect log4j2 logs into java.util.logging

I want to use Log4J2 API, but I want all logs to be processed by java.util.logging (which will use Tomcat implementation).我想使用 Log4J2 API,但我希望所有日志都由java.util.logging (将使用 Tomcat 实现)处理。 For example it's possible with SLF4J and slf4j-jdk14 library.例如,可以使用 SLF4J 和 slf4j-jdk14 库。 Is it possible with Log4J2? Log4J2 有可能吗? I've found log4j-jul library, but it seems to work the other way: JUL API will be redirected to Log4J implementation.我找到了 log4j-jul 库,但它似乎以另一种方式工作:JUL API 将被重定向到 Log4J 实现。

I'm aware that it's possible to replace Tomcat logging subsystem with Log4J2, but it seems a fragile solution to me.我知道可以用 Log4J2 替换 Tomcat 日志子系统,但这对我来说似乎是一个脆弱的解决方案。

Why do you consider using Log4j 2 to handle the logging as fragile?为什么您认为使用 Log4j 2 来处理脆弱的日志记录? Have you seen http://logging.apache.org/log4j/2.x/log4j-appserver/index.html ?你见过http://logging.apache.org/log4j/2.x/log4j-appserver/index.html吗?

No, Log4j does not provide a bridge to route logging to java.util.logging.不,Log4j 不提供将日志记录路由到 java.util.logging 的桥梁。 You can route the Log4j 2 API to SLF4J and then route that to java.util.logging.您可以将 Log4j 2 API 路由到 SLF4J,然后将其路由到 java.util.logging。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM