logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jacob Kjome <h...@visi.com>
Subject RE: Is it possible to set log levels at runtime?
Date Wed, 07 Apr 2004 18:24:26 GMT
Note that configureAndWatch() starts up a daemon thread and is not recommended
for use in a webapp, unless you like getting java.lang.ThreadDeath exceptions
upon application restart.  The thread doesn't die and, therefore, the
WebappClassLoader that was being discarded won't go away and logging (or maybe
even your application) will cease to work upon reload.

If you want to do it anyway, then you'll have to manually configure at
applicaion startup and call PropertyConfigurator.configureAndWatch() instead of
configure().  Make double sure to call LogManager.shutdown() at application
shutdown.


Jake

Quoting "Samir Shaikh (ex 444)" <sshaikh@worldres.com>:

> Hi,
> How do I configure log4j to use Configurator#configureAndWatch. My
> log4j.properties file looks like below. And are there any performance
> implications of doing this versus the default (Configurator#configure)
> 
> Thanks for your help.
> -Samir
> 
> ---excerpt from log4j.properties---
> log4j.rootCategory=INFO, LOGFILE
> 
> log4j.appender.S1=org.apache.log4j.DailyRollingFileAppender
> log4j.appender.S1.File=/usr/home/samirs/logs/search.log
> log4j.appender.S1.DatePattern='.'yyyyMMdd
> log4j.appender.S1.Append=true
> log4j.appender.S1.Threshold=DEBUG
> log4j.appender.S1.layout=org.apache.log4j.PatternLayout
> log4j.appender.S1.layout.ConversionPattern=%d [%t] [%-5p] %c.%m%n
> 
> ---end---
> 
> -----Original Message-----
> From: Shapira, Yoav [mailto:Yoav.Shapira@mpi.com]
> Sent: Wednesday, April 07, 2004 10:32 AM
> To: Log4J Users List
> Subject: RE: Is it possible to set log levels at runtime?
> 
> 
> 
> Hi,
> Yes, if you configure log4j using Configurator#configureAndWatch (rather
> than just Configurator#configure which is the default).
> 
> Yoav Shapira
> Millennium Research Informatics
> 
> 
> >-----Original Message-----
> >From: Samir Shaikh (ex 444) [mailto:sshaikh@worldres.com]
> >Sent: Wednesday, April 07, 2004 1:25 PM
> >To: 'Log4J Users List'; michael.mattox@verideon.com
> >Subject: RE: Is it possible to set log levels at runtime?
> >
> >Hi,
> >Can I change the log4j.properties file and expect the application to
> change
> >at runtime (i.e. w/o restarting the app)?
> >Thanks.
> >Samir
> >
> >-----Original Message-----
> >From: Shapira, Yoav [mailto:Yoav.Shapira@mpi.com]
> >Sent: Friday, April 02, 2004 6:04 AM
> >To: Log4J Users List; michael.mattox@verideon.com
> >Subject: RE: Is it possible to set log levels at runtime?
> >
> >
> >
> >Hi,
> >Yes, it's possible and has always been, as it's a core log4j feature.
> I
> >personally have a simple servlet that takes two string parameters, the
> >logger name and level, and does
> >Logger x = Logger.getLogger(request.getParameter("loggerName"));
> >x.setLevel(Level.toLevel(request.getParameter("loggingLevel")));
> >(I actually have a bit more error checking for null parameters, but the
> >above is the meat of it).
> >
> >As for JMX, I think it's possible but haven't tried it.
> >
> >Yoav Shapira
> >Millennium Research Informatics
> >
> >
> >>-----Original Message-----
> >>From: Michael Mattox [mailto:michael.mattox@verideon.com]
> >>Sent: Thursday, April 01, 2004 11:50 PM
> >>To: log4j-user@logging.apache.org
> >>Subject: Is it possible to set log levels at runtime?
> >>
> >>Is it possible to set log levels (for example go from INFO to debug)
> at
> >>runtime, without restarting the application??  Would it be possible to
> >set
> >>the log level with JMX?  I'm curious how people are doing this in
> >>production.  It seems like a very useful thing to turn on/off debug
> >logging
> >>for an app running in production.
> >>
> >>Thanks
> >>Michael
> >>
> >>
> >>
> >>---------------------------------------------------------------------
> >>To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> >>For additional commands, e-mail: log4j-user-help@logging.apache.org
> >
> >
> >
> >
> >This e-mail, including any attachments, is a confidential business
> >communication, and may contain information that is confidential,
> >proprietary
> >and/or privileged.  This e-mail is intended only for the individual(s)
> to
> >whom it is addressed, and may not be saved, copied, printed, disclosed
> or
> >used by anyone else.  If you are not the(an) intended recipient, please
> >immediately delete this e-mail from your computer system and notify the
> >sender.  Thank you.
> >
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> >For additional commands, e-mail: log4j-user-help@logging.apache.org
> 
> 
> 
> 
> This e-mail, including any attachments, is a confidential business
> communication, and may contain information that is confidential, proprietary
> and/or privileged.  This e-mail is intended only for the individual(s) to
> whom it is addressed, and may not be saved, copied, printed, disclosed or
> used by anyone else.  If you are not the(an) intended recipient, please
> immediately delete this e-mail from your computer system and notify the
> sender.  Thank you.
> 
> 
> ---------------------------------------------------------------------
> 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


Mime
View raw message