You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Alejandro Velasco <av...@hotmail.com> on 2002/03/19 19:17:43 UTC

RE: Re: Nightly log4j configuration

Thank you very much, Torgeir.
It works, though it now drops a great lot of debug messages. I'll read the 
documentation on log4j to decrease the number of debug messages to show.

Thanks
Alejandro



----------------
Original message:

The recent common-logging package (which struts uses) now defaults to
log4j if it can find it. Try removing log4j from your classpath.

Alternatively, you can initialize log4j before struts starts. Put this
in your web.xml file (before the struts reference);

     <servlet>
         <servlet-name>log4j-init</servlet-name>

<servlet-class>com.ecomda.common.config.Log4jInitServlet</servlet-class>
         <init-param>
             <param-name>log4j-init-file</param-name>
             <param-value>/WEB-INF/log4j.properties</param-value>
         </init-param>
         <load-on-startup>1</load-on-startup>
     </servlet>

The servlet looks like this;

package com.ecomda.common.config;

import javax.servlet.http.*;
import java.io.PrintWriter;
import java.io.IOException;
import org.apache.log4j.PropertyConfigurator;

public class Log4jInitServlet extends HttpServlet {

     public void init() {
         String prefix = getServletContext().getRealPath("/");
         String file = getInitParameter("log4j-init-file");

         if (file != null) {
             PropertyConfigurator.configure(prefix+file);
         }
     }

     public void doGet(HttpServletRequest req, HttpServletResponse res) { }
}

And the log4j.properties goes in WEB-INF;

# Set root category priority to DEBUG and its only appender to A1.

log4j.rootCategory=DEBUG,A1,F1
log4j.category.com=DEBUG,A1,F1

# A1 is set to be a ConsoleAppender.
log4j.appender.A1=org.apache.log4j.ConsoleAppender

# A1 uses PatternLayout.
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
# log4j.appender.A1.layout.ConversionPattern=%d %-4r [%t](%F:%L)  %-5p
%c %x - %m%n
log4j.appender.A1.layout.ConversionPattern=%d [%t](%F:%L) %-5p %x - %m%n

# F1 is set to be a RollingFileAppender that uses PatternLayout, add F1
to the desired categories to enable file trace
log4j.appender.F1=org.apache.log4j.RollingFileAppender
log4j.appender.F1.layout=org.apache.log4j.PatternLayout
log4j.appender.F1.layout.ConversionPattern=%p %t %c - %m%n
log4j.appender.F1.File=epd.log
log4j.appender.F1.MaxFileSize=100KB
log4j.appender.F1.MaxBackupIndex=1

log4j.category.org=DEBUG,A1,F1




--
-Torgeir



_________________________________________________________________
Hable con sus amigos en lĂ­nea, pruebe MSN Messenger: http://messenger.msn.es


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>