title: Conflict in log4j when loading libraries for DOM? (Other implementations of dom in classpath not allowed?)
body: <p>I am trying to put log4j in a web application in Tomcat 7.<br>
  I have the log4j library in the <code>WEB-INF\lib</code> of my web application.<br>
  I have the following log4j.xml under <code>WEB-INF\classes</code>  </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
      &lt;!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"&gt;
  
      &lt;log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"&gt;
  
        &lt;!-- Log output to Console --&gt;
        &lt;appender name="console" class="org.apache.log4j.ConsoleAppender"&gt; 
          &lt;param name="Target" value="System.out"/&gt; 
          &lt;layout class="org.apache.log4j.PatternLayout"&gt; 
            &lt;param name="ConversionPattern" value="%d [%t] %-5p %c - %m%n"/&gt; 
          &lt;/layout&gt; 
        &lt;/appender&gt;  
  
        &lt;appender name="rolling" class="org.apache.log4j.RollingFileAppender"&gt; 
          &lt;param name="file" value="myLogfile.log"/&gt;    
          &lt;param name="append" value="true" /&gt;
          &lt;param name="encoding" value="UTF-8" /&gt;  
          &lt;layout class="org.apache.log4j.PatternLayout"&gt; 
            &lt;param name="ConversionPattern" value="%d [%t] %-5p %c - %m%n"/&gt; 
          &lt;/layout&gt; 
        &lt;/appender&gt; 
  
        &lt;!-- Log to both Console and File --&gt;
        &lt;root&gt; 
          &lt;priority value ="debug" /&gt; 
          &lt;appender-ref ref="console" /&gt; 
          &lt;appender-ref ref="rolling" /&gt;
        &lt;/root&gt;  
  &lt;/log4j:configuration&gt;
  </code></pre>
  
  <p>I log e.g. in a servlet or filter that I know are loading but I can not see the output log anywhere.  </p>
  
  <p>E.g.  </p>
  
  <p><code>Logger log = Logger.getLogger(MyFilter.class);</code> </p>
  
  <p>and in <code>doFilter</code> I log i.e. <code>log.debug("logging information); log.error("logging information);</code></p>
  
  <p>I can not see the output in the Tomcat console as a result of the console <code>appender</code> and I don't see the <code>myLogfile.log</code> created either.   </p>
  
  <p>I am not sure where is this file supposed to be created.  </p>
  
  <p>I see only <code>System.out</code> statements from servlets and filters.  </p>
  
  <p>What am I doing wrong here?   </p>
  
  <p><strong>UPDATE:</strong><br>
  I have in the classpath <code>xercesImpl.jar</code> and <code>jaxb-impl.jar</code>. Could this cause an issue?</p>
  
  <p>I noticed the following exception I missed earlier in Tomcat console:  </p>
  
  <blockquote>
    <p>log4j:WARN Error during default initialization
    java.lang.NoClassDefFoundError: org/w3c/dom/ElementTraversal
            at java.lang.ClassLoader.defineClass1(Native Method)
            at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
            at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
            at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
            at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2823)
            at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1160)
            at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1655)
            at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1533)
            at org.apache.xerces.parsers.AbstractDOMParser.startDocument(Unknown
    Source)
            at org.apache.xerces.impl.dtd.XMLDTDValidator.startDocument(Unknown
    Source)
            at org.apache.xerces.impl.XMLDocumentScannerImpl.startEntity(Unknown
    Source)
            at org.apache.xerces.impl.XMLVersionDetector.startDocumentParsing(Unknown
    Source)
            at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
            at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
            at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
            at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
            at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
            at org.apache.log4j.xml.DOMConfigurator$2.parse(DOMConfigurator.java:767)
            at org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:866)
            at org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:773)
            at org.apache.log4j.helpers.OptionConverter.selectAndConfigure(OptionConverter.java:483)
            at org.apache.log4j.LogManager.(LogManager.java:127)
            at org.apache.log4j.Logger.getLogger(Logger.java:117)
            at com.test.MyFilter.(MyFilter.java:26)
            at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
            at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
            at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
            at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
            at java.lang.Class.newInstance0(Class.java:355)
            at java.lang.Class.newInstance(Class.java:308)
            at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:125)
            at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:256)
            at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:382)
            at org.apache.catalina.core.ApplicationFilterConfig.(ApplicationFilterConfig.java:103)
            at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4624)
            at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5281)
            at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
            at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:866)
            at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:842)
            at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:615)
            at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1095)
            at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1617)
            at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
            at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
            at java.util.concurrent.FutureTask.run(FutureTask.java:138)
            at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
            at java.lang.Thread.run(Thread.java:662) Caused by: java.lang.ClassNotFoundException: org.w3c.dom.ElementTraversal
            at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1688)
            at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1533)
            ... 48 more</p>
    
    <p>log4j:WARN No appenders could be found for logger (com.test.MyFilter).
    log4j:WARN Please initialize the log4j system properly. log4j:WARN See
    <a href="http://logging.apache.org/log4j/1.2/faq.html#noconfig" rel="nofollow">http://logging.apache.org/log4j/1.2/faq.html#noconfig</a> for more info.</p>
  </blockquote>