log4j PropertyConfigurator in tomcat6

where should you do the log4j config in a j2ee app using tomcat6?
bhomassAsked:
Who is Participating?
 
CEHJConnect With a Mentor Commented:
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
 
gksinghietCommented:
Check this tutorial with example:
http://www.laliluna.de/log4j-tutorial.html
0
 
afibarraCommented:
Try /WEB-INF/classes
0
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

 
bhomassAuthor Commented:
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
 
Sathish David Kumar NArchitectCommented:
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
 
CEHJCommented:
You could create a servlet with load on startup, from which you can make that call
0
 
bhomassAuthor Commented:
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
 
CEHJCommented:
>>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
 
bhomassAuthor Commented:
also for logback, do you need to make a call inside servlet which loads on start up also?
0
 
bhomassAuthor Commented:
maybe you just answered the last question?
0
 
CEHJCommented:
>>maybe you just answered the last question?

I did - twice ;-)

Let me know if it's still not clear
0
 
bhomassAuthor Commented:
worked like a charm. with no setup headache what so ever.
0
 
CEHJCommented:
Great :-)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.