?
Solved

Setting up Log4j in Websphere/Struts application

Posted on 2003-12-10
2
Medium Priority
?
1,755 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 9

Accepted Solution

by:
vzilka earned 150 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

Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
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.
Suggested Courses
Course of the Month12 days, 11 hours left to enroll

777 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