[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

log4j PropertyConfigurator in tomcat6

Posted on 2009-12-28
13
Medium Priority
?
444 Views
Last Modified: 2013-11-24
where should you do the log4j config in a j2ee app using tomcat6?
0
Comment
Question by:bhomass
13 Comments
 
LVL 5

Expert Comment

by:gksinghiet
ID: 26133931
Check this tutorial with example:
http://www.laliluna.de/log4j-tutorial.html
0
 
LVL 5

Expert Comment

by:afibarra
ID: 26133933
Try /WEB-INF/classes
0
 

Author Comment

by:bhomass
ID: 26134051
seems my question was not very clear.

I want to use the api org.apache.log4j.PropertyConfigurator.configureAndWatch(propfile) to config log4j.

where in a j2ee app do I make this call?
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 20

Expert Comment

by:Sathish David Kumar N
ID: 26135947
http://vegdave.wordpress.com/2006/08/31/how-to-configure-log4j-on-tomcat-for-one-of-your-apps/

in ur each file u can set like this !!

protected final Log logger = LogFactory.getLog(getClass());
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 26137255
You could create a servlet with load on startup, from which you can make that call
0
 
LVL 86

Accepted Solution

by:
CEHJ earned 500 total points
ID: 26137659
Unless you're tied to log4j, you should use Logback, which supersedes it. If you can do that, you can instruct Logback to scan for config changes declaratively, so your problem will disappear:

http://logback.qos.ch/manual/configuration.html#autoScan
0
 

Author Comment

by:bhomass
ID: 26141104
it seems if it's only for scanning .properties changes, the log4j configureAndWatch() would do that already.

what are the main advantages of moving to Logback?
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 26141175
>>it seems if it's only for scanning .properties changes, the log4j configureAndWatch() would do that already.

The point is you don't need code to do that

>>what are the main advantages of moving to Logback?
      
Increased performance and feature set
0
 

Author Comment

by:bhomass
ID: 26141215
also for logback, do you need to make a call inside servlet which loads on start up also?
0
 

Author Comment

by:bhomass
ID: 26141220
maybe you just answered the last question?
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 26141239
>>maybe you just answered the last question?

I did - twice ;-)

Let me know if it's still not clear
0
 

Author Comment

by:bhomass
ID: 26152258
worked like a charm. with no setup headache what so ever.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 26152601
Great :-)
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Suggested Courses
Course of the Month19 days, 5 hours left to enroll

834 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