logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ajay Dhanawade" <ajaykuma...@hotmail.com>
Subject Re: Help Needed!
Date Thu, 27 Sep 2001 20:37:27 GMT
<html><div style='background-color:'><DIV>
<P>Hi Mark,</P>
<P>I am using the FileWatchdog and PropertyConfigurator as suggested by u. But I am
not able to fix the puzzle. What I have now is individual parts and need your advice on placing
things together. </P>
<P>I want to use RollingFileAppender with run-time configuration of the debug, errors
and info messages (each type having a file). Now <STRONG>how to invoke the PropertyConfigurator
class as well as the classes extended from FileWatchdog and PropertyConfigurator ? Also how
to load the log4j config file?</STRONG></P>
<P>We are using WeblogicServer6.0sp1 running 2 webapps. We need to log messages of&nbsp;
this webapps to seperatelly and in three seperate files debug, errors and info respectively
.</P>
<P>Can u give me soem pointers and if possible sample code ?</P>
<P>Thanx in advance </P>
<P>CIAO<BR>Ajay<BR></P>
<UL>
<LI>From: Mark Masterson 
<LI>Subject: RE: modifying log levels through a management console 
<LI>Date: Tue, 05 Jun 2001 08:16:39 -0700 </LI></UL>
<HR>

<P><!--X-TopPNI-End--><!--X-MsgBody--><!--X-Subject-Header-Begin--><!--X-Subject-Header-End--><!--X-Head-of-Message--><!--X-Head-of-Message-End--><!--X-Head-Body-Sep-Begin--><!--X-Head-Body-Sep-End--><!--X-Body-of-Message--></P><PRE>You
don't need to jump through this many hoops to get this behavior - there
is an easier way to achieve dynamic, run-time re-configuration using
standard config files.  Specifically, you don't need to roll your own file
listener - Log4J already has one.  To do this, you subclass FileWatchdog and
the appropriate PropertyConfigurator.  For example, in our apps, we subclass
FileWatchdog and DOMConfigurator.  Then, you override doOnChange() and
configureAndWatch(), in your FileWatchdog sub-class and your
PropertyConfigurator sub-class, respectively.  In the PropertyConfigurator
sub-class's configureAndWatch() method, you set things up to use your
FileWatchdog sub-class (instead of a standard one), and in the doOnChange()
method of your FileWatchdog class, you call
BasicConfigurator.resetConfiguration().  In your application, you then need
to initialize Log4J by using your PropertyConfigurator class instead of the
standard one, i.e.;
"M2TraceDomConfigurator.configureAndWatch(configFile,configReloadDelay);"
and not "DOMConfigurator.configureAndWatch(configFile,configReloadDelay);".

Below are code snippets for the relevant spots from the implementation we're
using here - works fine.  This question has already been answered at least
once on this list, primarily by Ceki and Jim Moore - you should check the
list archives for more details.

Cheers,
Mark

public class M2TracePropertyWatchdog extends FileWatchdog{

&lt;blah, blah, blah&gt;

public void doOnChange() {
     BasicConfigurator.resetConfiguration();
     new DOMConfigurator().doConfigure(filename,
Category.getDefaultHierarchy());
   }

&lt;blah, blah, blah&gt;
}

public class M2TraceDomConfigurator extends DOMConfigurator {

&lt;blah, blah, blah&gt;

public static void configureAndWatch(String configFilename, long delay) {
    M2TracePropertyWatchdog pDog = new
M2TracePropertyWatchdog(configFilename);
    pDog.setDelay(delay);
    pDog.start();
  }

&lt;blah, blah, blah&gt;
}
<BR></PRE><BR><BR><BR>
<DIV>Keep the Faith! Good Happens!!<IMG height=12 src="http://64.4.8.24/emthup.gif"
width=12></DIV></DIV>
<DIV></DIV>
<DIV></DIV>
<DIV></DIV>&gt;From: "Mark Masterson" <MARK_MASTERSON@COMPUSERVE.COM>
<DIV></DIV>&gt;Reply-To: "LOG4J Users Mailing List" <LOG4J-USER@JAKARTA.APACHE.ORG>
<DIV></DIV>&gt;To: "LOG4J Users Mailing List" <LOG4J-USER@JAKARTA.APACHE.ORG>
<DIV></DIV>&gt;Subject: SNMP appender? 
<DIV></DIV>&gt;Date: Thu, 27 Sep 2001 20:47:56 +0200 
<DIV></DIV>&gt; 
<DIV></DIV>&gt;Anybody have an appender that emits SNMP messages? 
<DIV></DIV>&gt; 
<DIV></DIV>&gt; 
<DIV></DIV>&gt;---------------------------------------------------------------------

<DIV></DIV>&gt;To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org

<DIV></DIV>&gt;For additional commands, e-mail: log4j-user-help@jakarta.apache.org

<DIV></DIV>&gt; 
<DIV></DIV></div><br clear=all><hr>Get your FREE download of
MSN Explorer at <a href='http://go.msn.com/bql/hmtag_itl_EN.asp'>http://explorer.msn.com</a><br></html>

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