logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ebersole, Steven" <steven.ebers...@vignette.com>
Subject RE: Log4j Initialization
Date Tue, 16 Sep 2003 12:02:11 GMT
Not sure how this could be fixed in 1.3, as it really is not a log4j issue.
How could log4j definitively know that your app server redeployed an
application?  It could try to do it in a finalize method, but those are not
necessarily called, in which case you would still have stray threads
running.  The best log4j could do would be to provide hooks to stop the
watch thread and let the application programmer tie into that through maybe
a ServletContextListener or some similar server hook


> -----Original Message-----
> From: Andreas Bothner [ MTN - Innovation Centre ]
> [mailto:bothne_a@mtn.co.za]
> Sent: Tuesday, September 16, 2003 6:27 AM
> To: Log4J Users List
> Subject: RE: Log4j Initialization
> 
> 
> Sorry Joshua, I do not even think you have to call configure on the
> DOMConfigurator.  However, if you want to change the log configuration
> during runtime, you need to call configureAndWatch(filename, delay).
> Just be careful about this.  From reading the list previously, log4j
> creates a separate thread for this log watcher, which does not get
> killed when you redeploy the servlet in a J2EE container, 
> thus creating
> an additional thread with each redeployment.  I am hoping this will be
> fixed in version 1.3.
> 
> Regards,
> Andreas
> 
> -----Original Message-----
> From: Andreas Bothner [ MTN - Innovation Centre ] 
> Sent: Tuesday, 16 September 2003 13:04
> To: 'Log4J Users List'
> Subject: RE: Log4j Initialization
> 
> Hi Joshua,
> 
> I am a pretty new user, but I have read this code too and I 
> believe the
> following will answer your question.
> The debug level in this servlet is just used to determine if a line
> displaying the file configuration file should be printed out to the
> console.
> 
> I also believe that you do not need to specify the log4j.config system
> property if your configuration file has the name log4j.xml or
> log4j.properties, all you need to do is call
> DOMConfigurator.configure().  This will search the classpath for
> log4j.xml and if it cannot find it, it will try and find
> log4j.properties.
> 
> Maybe someone can corroborate this.
> 
> Regards,
> Andreas
> 
> -----Original Message-----
> From: White, Joshua A (HTSC, CASD) 
> [mailto:Joshua.White@thehartford.com]
> Sent: Tuesday, 16 September 2003 12:36
> To: 'Log4J Users List'
> Subject: Log4j Initialization
> 
> I had a couple questions regarding the following code which 
> is included
> in a weblogic sample application:
> 
> 
> /**
>  * <p>Controls Log4j logging level.  Implemented as a servlet so
>  * that logging levels can be adjusted by redeploying the webapp.
>  * Log file is determined by "log4j.config" set as a system
>  * property in the server startup file.</p>
>  *
>  * @author Copyright (c) 2003 by BEA Systems. All Rights Reserved.
>  */
> public class Log4jInit extends HttpServlet {
> 
>   public void init() {
> 
>     int debug = 0;
>     String value;
>     String logFile;
> 
>     logFile = System.getProperty("log4j.config");
>     value = getServletConfig().getInitParameter("debug");
> 
>     try {
> 	    debug = Integer.parseInt(value);
>     } catch (Throwable t) {
>         debug = 0;
>     }
> 
>     if (debug >= 1) {
>       SimpleDateFormat formatter = new SimpleDateFormat("MMM d, yyyy
> H:mm:ss a z");
>       Date today = new Date();
>       String output = "<"+formatter.format(today)+"> <Debug> 
> <MedRec>";
>       System.out.println(output+" Patient app log4j prop file:
> "+logFile);
>     }
> 
>     // if the log4j-init-file is not set, then no point in trying
>     if(logFile != null) {
>       if (logFile.toString().toLowerCase().endsWith(".xml")) {
>           DOMConfigurator.configure(logFile);
>       } else {
>         PropertyConfigurator.configure(logFile);
>       }
>     }
>   }
> }
> 
> 
> 1.	Does log4j need to be explicitly initialized this way?  If the
> log4j.properties or log4j.xml file is in the classpath, won't log4j
> initialize itself?
> 2.	This servlet gets a "debug" init parameter but never does
> anything
> with it.  How would you switch logging levels with this information.
> Can you switch levels at runtime?
> 
> Thanks,
> 
> Joshua
> 
> 
> 
> 
> 
> This communication, including attachments, is for the exclusive use of
> addressee and may contain proprietary, confidential or privileged
> information. If you are not the intended recipient, any use, copying,
> disclosure, dissemination or distribution is strictly 
> prohibited. If you
> are not the intended recipient, please notify the sender 
> immediately by
> return email and delete this communication and destroy all copies.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: log4j-user-help@jakarta.apache.org
> 
> 
> 
> NOTE: This e-mail message is subject to the MTN Group 
> disclaimer see http://www.mtn.co.za/email_disclaimer.asp
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: log4j-user-help@jakarta.apache.org
> 
> 

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


Mime
View raw message