问题描述
我在我的应用程序中使用Log4j并且有一些appender用于调试和错误。我在tomcat上测试了这个,工作正常。生成各自文件中的所有日志。但是当我在WAS6.1上部署代码时,所有日志都只在SystemOut.log中生成。
I am using Log4j in my application and have some appenders for debug and error. I tested this on tomcat and working fine. Generating all logs in their respective files. But when I deploy code on WAS6.1 all logs are getting generated only inside SystemOut.log.
请帮助!
推荐答案
问题可能是WebSphere 6.1在内部使用Jakarta Commons Logging(JCL),如果您的任何代码或第三方库也使用JCL,那么WebSphere的配置与您的应用程序冲突试图使用log4j。如果发生这种情况,你会看到你所看到的确切内容。
The problem might be that WebSphere 6.1 uses Jakarta Commons Logging (JCL) internally, and if any of your code or 3rd-party libraries also use JCL, WebSphere's configuration conflicts with your application trying to use log4j. If this is happening, you'll see exactly what you're seeing.
有多个和描述了解决此问题的方法。我们发现最简单的是在 META-INF / services $中创建一个名为
org.apache.commons.logging.LogFactory
的文件c $ c> Web应用程序的目录(在WAR归档的根目录中)。此文件必须包含以下行:
There are multiple references and blog posts that describe ways to address this. We've found the simplest to be creating a file named org.apache.commons.logging.LogFactory
in the META-INF/services
directory of your web application (in the root of the WAR archive). This file must contain the line:
org.apache.commons.logging.impl.Log4jFactory
(至少对于较新版本的WebSphere ...)另一个关键是必须从与log4j相同的位置加载JCL jar罐。例如既可以来自WEB-INF / lib,也可以来自共享库。因此,您不能依赖于从WebSphere自己提供的副本加载JCL。如果它们被,他们无法正确地看到对方。
(At least with newer versions of WebSphere...) Another key is that the JCL jar must be loaded from the same location as the log4j jar. e.g. either both from WEB-INF/lib or both from a shared library. Thus, you can't fall back on loading JCL from WebSphere's own provided copy. If they're loaded by different classloaders, they can't properly see each other.
这篇关于Websphere所有日志都将转到SystemOut.log的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!