Hi all!
 
I have a problem with my servlet. I want to use log4j.properties to configure Log4J. I have put log4j.properties in /WEB-INF/classes. I think that Log4J will look for log4j.properties in the classpath if I don't use BasicConfigurator.configure() . But Log4J couldn't find log4j.properties.  What's wrong? Please help me!
 
This is my servlet
 
--------------------------
public class MyActionServlet extends org.apache.struts.action.ActionServlet {
 
    static Category cat = Category.getInstance(MyActionServlet.class.getName());
    /** Creates new MyActionServlet */
    public MyActionServlet() {
    }
 
    public void init() throws javax.servlet.ServletException {
      super.init();
     
      // Congigure for Log4J
      // Won't use default values. Will use log4j.properties from class loader
      //BasicConfigurator.configure();
      cat.debug("Configure() completed.");
     
    }
     public void doGet(HttpServletRequest request,
         HttpServletResponse response)
      throws IOException, ServletException {
      ....
    }
 
     public void doPost(HttpServletRequest request,
         HttpServletResponse response)
      throws IOException, ServletException {
      .........
    }
   
}
 
------------------
But I always received this error:
 
log4j:ERROR No appenders could be found for category (MyActionServlet).
log4j:ERROR Please initialize the log4j system properly.
 
-----------------
 This is my log4j.properties file
 
# Set root category priority to DEBUG and its only appender to A1.
log4j.rootCategory=INFO, A1
# A1 is set to be a FileAppender which outputs to System.out.
log4j.appender.A1=org.apache.log4j.FileAppender
log4j.appender.A1.File=System.out
# A1 uses PatternLayout.
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n
 
--------------------------------
 
Regards,
Thai

Reply via email to