File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Other Open Source Projects and the fly likes dynamically change log4j logging level Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "dynamically change log4j logging level" Watch "dynamically change log4j logging level" New topic
Author

dynamically change log4j logging level

Jason Rodrigues
Greenhorn

Joined: Oct 20, 2005
Posts: 21
Hi is it possible to change the logging levels of log4j without brining down the server ?
Do you have any suggestion what i could take a look at or if you have sample code i could look at .
we are using jdk 1.4.2
aprpeicate your thoughts
-reeve
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 9930
    
159

Are you looking for something like this:



[My Blog] [JavaRanch Journal]
Jason Rodrigues
Greenhorn

Joined: Oct 20, 2005
Posts: 21
Well i need to do what you mentioned dynamically. That wont work for me. You must have noticed that each time you make a change to the configuration file, you have to restart your application. This can be a little bit cumbersome. I was wondering if there is a dyanmic way of changing the logging levels without restaring the server .
Gaurav Bhatia
Ranch Hand

Joined: Jan 01, 2007
Posts: 49
Using PropertyConfigurator.ConfigureAndWatch() you can enable log4j to watch any changes to the configuration file and apply those changes to the logging at runtime without any restart of the application.

Hope that helps
Gaurav


~Gaurav<br />SCJP5
Elie Hirschman
Ranch Hand

Joined: Dec 15, 2005
Posts: 37
I just came across this article, figured I would share:
http://springtips.blogspot.com/2007/07/changing-log4j-logging-levels.html
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: dynamically change log4j logging level
 
Similar Threads
abt log file
Logging info on server side
Redirecting Exceptions Or Exceptions to our own log files
confused between log4j and Jakarta Commons Logging
log4j : How to set append flase for backup files