Category

Using log4j in Websphere

Server configuration

WSAD already has an implementation of commons-logging that uses JRas as the implementation instead of log4j. This is in the server classpath which is loaded before your applications. So if you want to use log4j instead you have to change the server classpath.

  • Open the Server Perspective.
  • Double click on your server in the Outline view in the lower left corner (it’s named WebSphere v5.0 Test Environment). This will bring up an Editor View.
  • Choose the Applications tab.
  • Select your application and open the tree to the web application and set the Classloader mode to PARENT_LAST.
  • Select the application and set its mode to PARENT_LAST also.
  • Type control-s to save.
  • You have to restart the server for this to take effect.

websphere logging

The properties files in your Web project are now loaded before the parent classloader which loads the system classes. If you don’t do this your properties files are ignored.

Log files

So where are the log files? You can use an absolute path to a project directory. Then after running select the project directory in J2EE Navigator and press “Refresh”. The relative file names you specify in log4j.properties are relative to c:Program FilesIBMWebSphere Studio (or wherever you installed studio). There is already a logs directory there so perhaps in log4j.properties you should set your files like this:

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.