OK,
here is the configuration of log4j on my local machine:

-------------------- log4j.properties on D: -----------
#all classes have priority debug
log4j.rootCategory=DEBUG,R

#store all log information using the following appender
log4j.appender.R=org.apache.log4j.RollingFileAppender

#store log information in the following file
log4j.appender.R.File=e:\\log4j.log

#define the size of log files
log4j.appender.R.MaxFileSize=10000KB

#define number of backup files
log4j.appender.R.MaxBackupIndex=10

#define layout for log information
log4j.appender.R.layout=org.apache.log4j.PatternLayout

#define the conversion pattern
log4j.appender.R.layout.ConversionPattern=%d{DATE} [%t] %-5p %c:%M:%L - %m%n

-------------------- log4j.properties on D: -----------


-------------------- init servlet for my web-app ------
package somepackage;
public class InitServlet extends HttpServlet {
    public void init() {

PropertyConfigurator.configureAndWatch(getInitParameter("log4j-init-file"),

Long.decode(getInitParameter("log4j-refresh-interval-millis")).longValue());
    }
}
-------------------- init servlet for my web-app ------


-------------------- what you have to add to web.xml of your
webapp -----------
    <servlet>
       <servlet-name>log4j-init</servlet-name>
       <servlet-class>somepackage.InitServlet</servlet-class>
       <init-param>
          <param-name>log4j-init-file</param-name>
          <param-value>d:/log4j.properties</param-value>
       </init-param>
       <init-param>
          <param-name>log4j-refresh-interval-millis</param-name>
          <param-value>10000</param-value>
       </init-param>
       <load-on-startup>1</load-on-startup>
    </servlet>
-------------------- what you have to add to web.xml of your
webapp -----------

This configuration works for me on NT. For Linux you only have to change
paths.
I can change the DEBUG level at runtime to INFO and - in the worst case -
after 10 seconds log4j is reconfigured.

Regards
Thomas



> > Your log4j.properties looks OK for me.
> > You have to reinitialize log4j to get rid of your DEBUG messages.
> >
> > There are at least to ways to do this:
> > 1) Restart Tomcat. ( Not good for production system).
> > 2) Use a init Servlet for your webapps and initialize log4j with
> > PropertyConfigurator.configureAndWatch or
> DOMConfigurator.configureAndWatch
> > See API docs and user manual for details.
>
> It's no problem for me to restart Tomcat.  I'll power cycle the
> machine if it helps.  I'll do anything I need to do so that I can stop
> getting DEBUG level messages, because the alternative is that I have
> to go through the code and manually remove all the logging statements.
> It seems that there must be a way of specifying this in the properties
> file, but I can't find it.  I have restarted it a hundred times with
> this config file:
>
> # Set root category priority to DEBUG and its only appender to A1.
> log4j.rootCategory=INFO, A1
>
> log4j.threshold=INFO
> log4j.disable=DEBUG
>
> # where to append to
> log4j.appender.A1=org.apache.log4j.FileAppender
>
> # set up the filename
> log4j.appender.A1.File=/tmp/test.log
>
> # A1 uses PatternLayout.
> log4j.appender.A1.layout=org.apache.log4j.PatternLayout
> log4j.appender.A1.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n
>
> and I still get logs full of DEBUG messages.  I read in the FAQ:
>
> > What are Categories?
> >
> > The notion of categories lies at the heart of log4j.
> Categories define
> > a hierarchy and give the programmer run-time control on which
> > statements are printed or not.
>
> so it sounds like this is something which should be possible.  Do I
> need an XML config file?  Is there some patch I need to apply to
> log4j?
>
> Any tips would be welcome.  I also read through all the mailing list
> archives and there were some threads on this issue, and I tried their
> recomendations but none of it helps.
>
> Thanks for any sugestions.
>
> --
> To unsubscribe, e-mail:
> <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>
>


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

Reply via email to