且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

WebSphere-无法加载Logmanager"org.apache.logging.log4j.jul.LogManager";

更新时间:2021-10-03 23:15:01

这里的问题是使用java.util.logging(JUL)的不仅是您的应用-服务器的核心也是如此,并且通过尝试将JUL重定向到Log4J并使用系统属性(适用于整个JVM)对其进行强制,您实际上是在尝试通过Log4J设置来重定向服务器中的所有日志记录.服务器的messages.log中包含的所有内容都将显示在您的日志记录中.

The problem here is that it's not just your app that uses java.util.logging (JUL) - so does the core of the server, and by attempting to redirect JUL to Log4J and enforcing it with a system property (which applies to the entire JVM), you're essentially attempting to redirect all logging in the server through your Log4J setup. Anything that would be in the server's messages.log is going to show up in your logging instead.

如果您仍然真的想要这样做,最简单的解决方案可能是将log4j-jul jar放入JVM启动类路径,因此对于Java系统加载器来说是可见的(您可能必须对任何依赖项执行相同的操作和配置文件).同样,您将覆盖所有服务器级别的日志记录,因此我不希望这是受支持的配置(如果打开支持案例,他们将不想查看您的自定义Log4J格式的日志以获取服务器详细信息),但从理论上讲应该可以正常工作.

If you still REALLY want to do this, the simplest solution is probably to put the log4j-jul jar into the JVM launch class path, so it's visible to the Java system loader (you may have to do the same with any dependencies and configuration files). Again, you're overriding all of the server-level logging, so I wouldn't expect that this would be a supported configuration (if you open a support case, they're not gonna want to review your custom Log4J-formatted logs for server details), but it should theoretically be functional.