Using Commons-Logging 1.1 with Log4j on WebSphere 6.0

Log4j does seem to work out of the box with Websphere 6 so I cobbled together some tips and advice from the web and wrote this mini guide. It was a couple of years but hopefully be useful to someone.

WebSphere uses commons-logging and so it’s in the root classloader. In addition, WebSphere 6.0 ships a with the following properties set:


Therefore by default the application will use JDK logging and not log4j. The solution is to ensure that the right classloader mode is set and the application has an appropriate and use the official released version 1.1 of commons-loggin api:

Set application classloader mode as PARENT_LAST. This can be changed in eclispes EAR file deployment descriptor menu. This tells websphere to load the parent files last giving the application files priority. (the parent being the websphere root)

Also, create a new to the application classpath with the following entries:

The priority flag was introduced in Commons Logging 1.1 to allow an ordering based on priority. To ensure that an application’s will take precedence over WebSphere’s file, a priority of greater that 0.0 must be set.  I changed mine to 5 (just to be sure 😉 ).

So basically the overrides the one packaged in websphere and returns it to the default logging system which is log4j.

NOTE: You also have to replace the commons-logging-api.jar that comes supplied with websphere, because IBM use the API and which doesn’t contain the log4j logger implementation. 🙁


<Rational Instal DIR>\Rational\SDP\6.0\runtimes\base_v6\lib\commons-logging-api.jar
With the commons-logging-api.jar downloaded from

You should also import include it in your go to project properties, java build path and import external jar. Ensure it’s imported above the websphere runtime library otherwise it’ll read the other one first. You can change the order of the imports in project prop > java build path > order and export.

LOG4J Config
To configure log4j you’ll need to create a log4j.propertuies file or a log4j.xml file. This can be located in the application classpath (same level as the ‘com’ directory). Ideally this should be located outside of the EAR/WAR file, where it can be easily editing whilst the application is running without the need to redeploy.

Note: When you build the project both and should be copied to the WebContent>Web-Inf>Classes


  • Created and in java classpath.
  • Change application classloader mode as PARENT_LAST
  • Import the commons-logging 1.1 jar file
  • Ensure imported jar in imported before Websphere runtime
  • Clean, Build and redeploy (also restart websphere)

More info: