I have this two files to configure my log4j in a web context, using tomcat 4.0.6(included in netbeans 3.5) and jdk 1.4.1-b21 <!-- 1. log4j.xml, in WEB-INF/classes -> <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd" [ <!ENTITY pool-categories SYSTEM "pool-categories.ent"> ]> <log4j:configuration debug="true"> <appender name="AppenderConsola" class="org.apache.log4j.ConsoleAppender"> <layout class="org.apache.log4j.PatternLayout"> <param name="ConversionPattern" value="%m%n"/> </layout> </appender> <appender name="AppenderTexto" class="org.apache.log4j.RollingFileAppender"> <param name="File" value="C:\\Archivos de programa\\NetBeans IDE 3.5 \\tomcat406\\webapps\\ipsa\\errores\\Log.log" /> <layout class="org.apache.log4j.PatternLayout"> <param name="ConversionPattern" value="%p %c - %m%n"/> </layout> </appender> <appender name="AppenderFactor5" class="org.apache.log4j.RollingFileAppender"> <param name="File" value="C:\\Archivos de programa\\NetBeans IDE 3.5 \\tomcat406\\webapps\\ipsa\\errores\\LogFactor5.log" /> <param name="MaxFileSize" value="500KB" /> <layout class="org.apache.log4j.PatternLayout"> <param name="ConversionPattern" value="[slf5s.start]%d{yyyy/MM/dd HH:mm:ss}[slf5s.DATE]%p[slf5s.PRIORITY]%c[slf5s.CATEGORY]%m[slf5s.MESSAGE]%n"/> </layout> </appender> <!-- - Se definen las categorias para el pool. --> &pool-categories; </log4j:configuration> <!-- 2. pool-categories.ent, in WEB-INF/classes -> <category name="co.com.winet.util.connpool"> <priority value="DEBUG" /> <appender-ref ref="AppenderConsola" /> <appender-ref ref="AppenderTexto" /> </category> <category name="co.com.winet.util.connpool.ConexionesPool$GeneradorLog"> <priority value="DEBUG" /> <appender-ref ref="AppenderFactor5" /> </category> The tomcat console is as follows: Starting service Tomcat-Standalone Apache Tomcat/4.0.6 Starting service Tomcat-Apache Apache Tomcat/4.0.6 log4j:ERROR Parsing error on line 0 and column 0 log4j:ERROR File "dummy://log4j.dtdpool-categories.ent" not found. log4j:ERROR Could not parse input source [org.xml.sax.InputSource@1e4853f]. org.xml.sax.SAXException: Stopping after fatal error: File "dummy://log4j.dtdpool-categories.ent" not found. at org.apache.xerces.framework.XMLParser.reportError (XMLParser.java:1245) at org.apache.xerces.readers.DefaultEntityHandler.startReadingFromExternalEntity (DefaultEntityHandler.java:780) at org.apache.xerces.readers.DefaultEntityHandler.startReadingFromEntity (DefaultEntityHandler.java:663) at org.apache.xerces.framework.XMLDocumentScanner$ContentDispatcher.dispatch (XMLDocumentScanner.java:1264) at org.apache.xerces.framework.XMLDocumentScanner.parseSome (XMLDocumentScanner.java:381) at org.apache.xerces.framework.XMLParser.parse(XMLParser.java:1098) at org.apache.xerces.jaxp.DocumentBuilderImpl.parse (DocumentBuilderImpl.java:195) at org.apache.log4j.xml.DOMConfigurator.doConfigure (DOMConfigurator.java:665) at org.apache.log4j.xml.DOMConfigurator.doConfigure (DOMConfigurator.java:616) at org.apache.log4j.xml.DOMConfigurator.doConfigure (DOMConfigurator.java:602) at org.apache.log4j.helpers.OptionConverter.selectAndConfigure (OptionConverter.java:460) at org.apache.log4j.LogManager.<clinit>(LogManager.java:113) at org.apache.log4j.Logger.getLogger(Logger.java:85) at co.com.winet.util.connpool.PoolManager.<clinit>(PoolManager.java:50) ...
1.2.12 candidate Is there a "simple" fix that can be applied for this?
I'll take this one. I fixed a similar issue with the JoranConfigurator. The problem is that the call to the parser used an InputStream (just a series of bytes) instead of an InputSource, URL or a File which would provide both the sequence of bytes and a base for resolving relative URL's.
The problem had been fixed as part of the Joran development on the CVS HEAD, but there were no tests for it. The fix for this bug added DOMTest::test4 to both the CVS HEAD and v1.2_branch to check for the proper handling of external entities. The fix on the v1.2 branch is mimicked the approach in the Joran configuration by introducing a delegate that is called to actually perform the parsing. The original approach was to create an InputSource. Since there is no clean way prior to create a URL for an arbitrary file prior to JDK 1.4, the InputSource would not have a valid URL and attempts to resolve entities relative to the InputSource would fail. Using the delegate, the parser can be passed a File which it knows how to use to resolve relative URL's. The change should not change any successful call to DOMConfigurator. For most error conditions, the change should only result in improved diagnostic messages since the parser now knows more about the source and has more robust error reporting code than we had. If there are multiple error conditions, the change may affect which one gets reported. For example, if there is no XML parser available and the configuration file does not exist, the original code will report the missing file and the new code will report the missing parser.