File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "dynamically change log4j logging level" Watch "dynamically change log4j logging level" New topic

dynamically change log4j logging level

Jason Rodrigues

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
Jaikiran Pai

Joined: Jul 20, 2005
Posts: 10441

Are you looking for something like this:

[My Blog] [JavaRanch Journal]
Jason Rodrigues

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<br />SCJP5
Elie Hirschman
Ranch Hand

Joined: Dec 15, 2005
Posts: 37
I just came across this article, figured I would share:
I agree. Here's the link:
subject: dynamically change log4j logging level
It's not a secret anymore!