Solved

Setting up Log4j in Websphere/Struts application

Posted on 2003-12-10
2
1,697 Views
Last Modified: 2008-02-01
Hi,

I'm trying to enable log4j logging via commons-logging in a Struts application being developed in Websphere Studio - currently its just using SimpleLog - but cannot get it to log to a file.

I've created a commons-logging.properties file and a log4j.properties file, which I've placed under the JavaSource folder (i.e. they get moved to the web-inf/classes folder upon deployment). These are shown below:

commons-logging.properties:

org.apache.commons.logging.Log=org.apache.commons.logging.impl.Log4JLogger

log4j.properties:

log4j.rootLogger=DEBUG, rolling
log4j.appender.rolling=org.apache.log4j.RollingFileAppender
log4j.appender.rolling.File=output.log
log4j.appender.rolling.MaxFileSize=100KB
log4j.appender.rolling.MaxBackupIndex=1
log4j.appender.rolling.layout=org.apache.log4j.SimpleLayout

Can anyone tell me why the output file isn't being created? I suspect that the properties files aren't being found and so log4j is not being instantiated.

Cheers,

Steve

0
Comment
Question by:stevebeech
2 Comments
 
LVL 9

Accepted Solution

by:
vzilka earned 50 total points
ID: 9913744
Although this should work, I usually prefer editing the startup script of the app server and add a -D command to the JVM.
The "-Dlog4j.configuration=foobar.txt" will tell log4j where to find its configuration file (in this case foobar.txt).

Also try "-Dlog4j.debug" to see the log4J messages .
0
 

Author Comment

by:stevebeech
ID: 9919894
Thanks Vzilka,

I tried this but still couldn't get Websphere to take notice.

In the end, I removed the commons-logging and just used log4j alone, as per http://www.webagesolutions.com/knowledgebase/waskb/waskb004/index.html

Thanks anyway,

Steve
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now