Websphere all logs are going to SystemOut.log

10,655

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.

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

(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.

Share:
10,655
Dev G
Author by

Dev G

Work on Java/J2EE, JavaScript based web frameworks. Love to read/learn and R&D on new technologies. Now days trying IoT gadgets using Arduino and RaspPi

Updated on July 13, 2022

Comments

  • Dev G
    Dev G almost 2 years

    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.

    Please help!