Problem with log4j.xml


General J2EE: Problem with log4j.xml

  1. Problem with log4j.xml (4 messages)

    I'm using log4j in a struts application on Weblogic 7.
    I've configured and placed my log4j.xml file in the classpath of my webapp (WEB-INF\classes).
    But it seems it can't be found because:
     - the logs doesn't work properly
     - when I deploy/start my webapp, I get this error msg:
    log4j:ERROR Could not open [log4j.xml]. log4j.xml: Le fichier spÚcifiÚ est introuvable
            at;I)I(Native Method)
            at;I);(Unknown Source)
            at<init>(Ljava.lang.String;)V(Unknown Source)
            at org.apache.log4j.xml.DOMConfigurator.doConfigure(Ljava.lang.String;Lorg.apache.log4j.spi.LoggerRepository;)V(
            at org.apache.log4j.xml.DOMConfigurator.configure(Ljava.lang.String;)V(
            at org.apache.struts.action.ActionServlet.initModulePlugIns(Lorg.apache.struts.config.ModuleConfig;)V(ActionServ
            at org.apache.struts.action.ActionServlet.init()V(
            at javax.servlet.GenericServlet.init(Ljavax.servlet.ServletConfig;)V(
            at weblogic.servlet.internal.ServletStubImpl$;(
            at weblogic.servlet.internal.ServletStubImpl.createServlet()Ljavax.servlet.Servlet;(
            at weblogic.servlet.internal.ServletStubImpl.createInstances()V(
            at weblogic.servlet.internal.ServletStubImpl.prepareServlet(Lweblogic.servlet.internal.RequestCallback;)V(Servle
            at weblogic.servlet.internal.WebAppServletContext.preloadServlet(Ljava.lang.String;)V(
            at weblogic.servlet.internal.WebAppServletContext.preloadServlets()V(
            at weblogic.servlet.internal.WebAppServletContext.preloadResources()V(
            at weblogic.servlet.internal.WebAppServletContext.setStarted(Z)V(
            at weblogic.servlet.internal.WebAppModule.start()V(
            at weblogic.j2ee.J2EEApplicationContainer.start([Lweblogic.j2ee.J2EEApplicationContainer$Component;)V(J2EEApplic
            at weblogic.j2ee.J2EEApplicationContainer.activate(Ljava.lang.String;[

            at weblogic.drs.internal.SlaveCallbackHandler$1.execute(Lweblogic.kernel.ExecuteThread;)V(SlaveCallbackHandler.j
            at weblogic.kernel.ExecuteThread.execute(Lweblogic.kernel.ExecuteRequest;)V(
            at java.lang.Thread.startThreadFromVM(Ljava.lang.Thread;)V(Unknown Source)

    Does anyone could help me to solve this problem?

    Threaded Messages (4)

  2. Problem with log4j.xml[ Go to top ]

    Yes I too have a same problem with weblogic8.1.
    When I pass log4j.xml to propertyconfigurator, it does nothing.

    But file works fine.

  3. Problem with log4j.xml[ Go to top ]

    That's exactly what happened for me too, even using DOMConfigurator rather than PropertyConfigurator (I've red that we have to use DOMConfigurator with log4j.xml).
  4. Solution[ Go to top ]

    After more than 2 days searching the web, I've found the way to solve this problem:
    I get the log4j.xml file like this in the log4j init class:
  5. Solution[ Go to top ]

    This is true for getting all the files which are in the WEB-INF/classes folder when you use the weblogic workshop. The reason for this is that we write the java code in a Java project in the weblogic workshop which does not have a container. This java project is internally used either by a web project, web service project, etc which have containers. So to get the files, we use the Thread.currentThread().getContextClassLoader().getResource("log4j.xml")
    which gets the file from the current container from where the java code was called (eg. from the WEB-INF/classes of the web project or web service project)

    It might be a good thing to just have one file in the WEB-INF classes which has the path location of another file XYZ at some constant location and we use the file XYZ for all our constants.