-------Original Message-------
From: Shapira, Yoav [mailto:[EMAIL PROTECTED] 
Sent: Thursday, January 29, 2004 1:06 PM
To: Tomcat Users List
Subject: RE: log4j config problem

Instead of relying on log4j's default initialization, you can add a
simple line like
PropertyConfigurator.configure(getServletContext().getResource("/WEB-INF
/log4j.properties")) to your servlet's init method and you'll be all
set.

Yoav Shapira
-----End Of Original Message-----

Actually I am trying to avoid this in this application:).  This is what I dug
out from my CVS(another project), you can see the pain I had to go through to
get it working:).  

                /* We used to do it this way, but I couldn't get it to work with
                        configureAndWatch 
                // find the location of the log4j properties
                String log4jConfig =
(String)getServletConfig().getInitParameter(LOG4J_CONFIG);              
                // configure log4j subsystem
        
PropertyConfigurator.configure(getServletContext().getResource(log4jConfig));*/
                
                // Configure and watch is nice, because it will watch for
changes to the
                //      log4j.properties file, and apply those changes without
having to restart
                //      the webapp or Tomcat.  It will check every 60 seconds.
                // NOTE: the hard-coded file location
(../webapps/ROOT/log4j.properties)assumes
                //      the current directory is Tomcat's /bin directory.
        
PropertyConfigurator.configureAndWatch("../webapps/log4j.properties", 60000);

I don't want to hardcode the path in the Java code. I think it's better to take
care of business in web.xml. But I might have to yield eventaully:-(.

Thanks for the help!


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to