Using log4j with WebSphere

by lichen 3/12/2007 3:05:00 PM

I have been developing a web service using WebSphere. I tried to add logging functionality using log4j. I used a servlet to initialize the log4j configuration using the suggestion in http://logging.apache.org/log4j/docs/manual.html. I also used the example log4j.xml files in http://www.laliluna.de/log4j-tutorial.html. I added the log4j jar file into the WEB-INF/lib directory and added the log4j.xml file into the WEB-INF/classes directory. However, I would lose my log4j.xml file whenever I rebuild my project. This because the entire WEB-INF/classes directory is rewritten when the project is rebuilt. So I moved the log4j.xml into the WEB-INF directory, along with other .xml files. However, when I run the project, I would get:

  • R log4j:WARN No appenders could be found for logger (root).
  • R log4j:WARN Please initialize the log4j system property.

I googled around a bit and found that the log4j.xml file needs to be in the classes directory. So I copied to log4j.xml file into the JavaSource directory. When the project is rebuilt, the file is automatically copied to the the WEB-INF/classes directory. When I ran the program again, it worked beautifully.

Some additional notes:

  1. log4j.dtd needs to be in the same directory as log4j.xml.
  2. When I test the web service using WebSpere v5.1 test environment, the log file is found in the root directory of my WebSphere Studio.

Currently rated 3.0 by 2 people

  • Currently 3/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

Java | Web Service

Billets liƩs

Comments are closed

Powered by BlogEngine.NET 1.2.0.0
Theme by Mads Kristensen

About the author

Name of author Author name
Something about me and what I do.

E-mail me Send mail

Calendar

<<  September 2010  >>
MoTuWeThFrSaSu
303112345
6789101112
13141516171819
20212223242526
27282930123
45678910

View posts in large calendar

Pages

    Recent comments

    Authors

    Tags

      Disclaimer

      The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

      © Copyright 2010

      Sign in