You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Elihu Smails <el...@gmail.com> on 2005/03/18 14:44:50 UTC

dynamically reloading log4j config file

Is it possible for Log4J to dynamically reload the configuration file?
 For instance, if I have my configuration set to INFO, and there is a
problem in my program and want to increase the logging to DEBUG, could
I change the config file to reflect DEBUG and then call
PropertyConfigurator.configure( String ) ?

Thank you in advance for the help.

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Re: dynamically reloading log4j config file

Posted by Elihu Smails <el...@gmail.com>.
Thanks for the information.  Yes, this is a server based application
and not a web application, so I think I am OK.  I will take a look at
some other implementations to see what else is different and maybe use
another approach.




On Sun, 20 Mar 2005 23:23:27 -0600, Jacob Kjome <ho...@visi.com> wrote:
> At 01:45 PM 3/18/2005 +0000, you wrote:
>  >Use the following
>  >
>  >URL url = this.getClass().getResource("log4j.properties");
>  >// Configure the properties and observe the file every 2 seconds
>  >PropertyConfigurator.configureAndWatch(url.getPath(), 2000);
>  >
> 
> Please avoid configureAndWatch.  It uses a non-daemon thread and can cause
> issues with shutting down classloaders in containers.  I would use a
> dynamic configuration application.  If you are using a webapp, try the
> various configuration servlets out there.  There is one in the sandbox, and
> enhanced version in the wiki, and others listed on Log4j's download page in
> the 3rd party section.  If it is a command line app, then configureAndWatch
> is probably ok.
> 
> Jake
> 
>  >-----Original Message-----
>  >From: Elihu Smails [mailto:elihusmails@gmail.com]
>  >Sent: 18 March 2005 13:45
>  >To: log4j-user@logging.apache.org
>  >Subject: dynamically reloading log4j config file
>  >
>  >Is it possible for Log4J to dynamically reload the configuration file?
>  > For instance, if I have my configuration set to INFO, and there is a
>  >problem in my program and want to increase the logging to DEBUG, could
>  >I change the config file to reflect DEBUG and then call
>  >PropertyConfigurator.configure( String ) ?
>  >
>  >Thank you in advance for the help.
>  >
>  >---------------------------------------------------------------------
>  >To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
>  >For additional commands, e-mail: log4j-user-help@logging.apache.org
>  >
>  >
>  >---------------------------------------------------------------------
>  >To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
>  >For additional commands, e-mail: log4j-user-help@logging.apache.org
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
> 
>

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


RE: dynamically reloading log4j config file

Posted by Jacob Kjome <ho...@visi.com>.
At 01:45 PM 3/18/2005 +0000, you wrote:
 >Use the following
 >
 >URL url = this.getClass().getResource("log4j.properties");
 >// Configure the properties and observe the file every 2 seconds
 >PropertyConfigurator.configureAndWatch(url.getPath(), 2000);
 >

Please avoid configureAndWatch.  It uses a non-daemon thread and can cause 
issues with shutting down classloaders in containers.  I would use a 
dynamic configuration application.  If you are using a webapp, try the 
various configuration servlets out there.  There is one in the sandbox, and 
enhanced version in the wiki, and others listed on Log4j's download page in 
the 3rd party section.  If it is a command line app, then configureAndWatch 
is probably ok.


Jake

 >-----Original Message-----
 >From: Elihu Smails [mailto:elihusmails@gmail.com]
 >Sent: 18 March 2005 13:45
 >To: log4j-user@logging.apache.org
 >Subject: dynamically reloading log4j config file
 >
 >Is it possible for Log4J to dynamically reload the configuration file?
 > For instance, if I have my configuration set to INFO, and there is a
 >problem in my program and want to increase the logging to DEBUG, could
 >I change the config file to reflect DEBUG and then call
 >PropertyConfigurator.configure( String ) ?
 >
 >Thank you in advance for the help.
 >
 >---------------------------------------------------------------------
 >To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
 >For additional commands, e-mail: log4j-user-help@logging.apache.org
 >
 >
 >---------------------------------------------------------------------
 >To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
 >For additional commands, e-mail: log4j-user-help@logging.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


RE: dynamically reloading log4j config file

Posted by Mark Benussi <ma...@hotmail.com>.
Use the following

URL url = this.getClass().getResource("log4j.properties");
// Configure the properties and observe the file every 2 seconds
PropertyConfigurator.configureAndWatch(url.getPath(), 2000);

-----Original Message-----
From: Elihu Smails [mailto:elihusmails@gmail.com] 
Sent: 18 March 2005 13:45
To: log4j-user@logging.apache.org
Subject: dynamically reloading log4j config file

Is it possible for Log4J to dynamically reload the configuration file?
 For instance, if I have my configuration set to INFO, and there is a
problem in my program and want to increase the logging to DEBUG, could
I change the config file to reflect DEBUG and then call
PropertyConfigurator.configure( String ) ?

Thank you in advance for the help.

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org