Jakarta Commons Logging

with

Log4j

running in

WebSphere V5

Below are instructions for configuring the use of Log4j through the Commons Logging wrapper in WebSphere v5.x. (WebSphere v6.0.x instructions)

  1. Add the log4j and commons logging JARs to the root of the EAR project.

  2. Add a properties directory to the root of the EAR project.

  3. Add your log4j.properties file to the properties directory.

  4. For each WAR project that needs logging, perform the following steps.

    1. Open the properties dialog.
    2. Select Java JAR Dependencies.
    3. Select the commons-logging and log4j libraries.

      This much adds the JAR files to the classpath of the web app. But we still need to add the properties directory. WSAD does not permit adding this directly. Moreover, the format of this entry is different for the WSAD test environment than it is for WAS. So the next two entries must be added manually.

    4. In the WSAD web project, navigate to the WebContent/META-INF directory and edit the MANIFEST.MF file.
    5. Click the source tab. Add the two lines exactly as shown below. The underscore character (_) indicates a blank space.
      Class-Path:_MyLib1.jar_
      _MyLib2.jar_
      _commons-logging.jar_
      _log4j-1.2.8.jar_
      _../ContractWebApp/properties_
      _properties 
      Note that the last line does not end with a space. The other entries end and begin with a space.

    6. Create a directory in the web project under WebContent/META-INF called services.
    7. In this services directory, create a new file called org.apache.commons.logging.LogFactory. It only needs to contain the following line
            org.apache.commons.logging.impl.LogFactoryImpl

There is no need to change classloader delegation modes for this procedure. It should work irrespective of delegation mode.