logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ceki Gülcü <c...@qos.ch>
Subject EntityResolver code+DTD issues
Date Tue, 18 Feb 2003 21:43:45 GMT

Interestingly enough, the Log4jEntityResolver code as proposed in 1.2.8 
(not yet released) does not work with the XML parser that ships in JDK 1.4 
although it works fine with xerces.

Trying to parse the following config file with DOMConfigurator and the JDK 
1.4 XML parser will barf:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">

<log4j:configuration xmlns:log4j='http://jakarta.apache.org/log4j/'>
   ...
</log4j:configuration>

For example:

log4j: Trying to find [log4j.xml] using context classloader 
sun.misc.Launcher$AppClassLoader@12f6684.
log4j: Trying to find [log4j.xml] using 
sun.misc.Launcher$AppClassLoader@12f6684 class loader.
log4j: Trying to find [log4j.xml] using ClassLoader.getSystemResource().
log4j: Trying to find [log4j.properties] using context classloader 
sun.misc.Launcher$AppClassLoader@12f6684.
log4j: Trying to find [log4j.properties] using 
sun.misc.Launcher$AppClassLoader@12f6684 class loader.
log4j: Trying to find [log4j.properties] using ClassLoader.getSystemResource().
log4j: Could not find resources to perform automatic configuration.
log4j: System property [javax.xml.parsers.DocumentBuilderFactory] is :null
log4j: Standard DocumentBuilderFactory search succeded.
log4j: DocumentBuilderFactory is: 
org.apache.crimson.jaxp.DocumentBuilderFactoryImpl
log4j:ERROR Parsing error on line 2 and column -1
log4j:ERROR Relative URI "log4j.dtd"; can not be resolved without a base URI.
log4j:ERROR Could not parse input source [org.xml.sax.InputSource@1abab88].
org.xml.sax.SAXParseException: Relative URI "log4j.dtd"; can not be 
resolved without a base URI.
         at org.apache.crimson.parser.Parser2.fatal(Parser2.java:3182)
         at org.apache.crimson.parser.Parser2.fatal(Parser2.java:3176)
         at org.apache.crimson.parser.Parser2.resolveURI(Parser2.java:2758)
         at 
org.apache.crimson.parser.Parser2.maybeExternalID(Parser2.java:2730)
         at 
org.apache.crimson.parser.Parser2.maybeDoctypeDecl(Parser2.java:1129)
         at org.apache.crimson.parser.Parser2.parseInternal(Parser2.java:489)
         at org.apache.crimson.parser.Parser2.parse(Parser2.java:305)
         at 
org.apache.crimson.parser.XMLReaderImpl.parse(XMLReaderImpl.java:442)
         at 
org.apache.crimson.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:185)
         at org.apache.log4j.xml.DOMConfigurator.doConfigure(Unknown Source)
         at org.apache.log4j.xml.DOMConfigurator.doConfigure(Unknown Source)
         at org.apache.log4j.xml.DOMConfigurator.doConfigure(Unknown Source)
         at org.apache.log4j.xml.DOMConfigurator.configure(Unknown Source)
         at chapter3.MyApp3.main(MyApp3.java:13)
log4j:WARN No appenders could be found for logger (chapter3.MyApp3).
log4j:WARN Please initialize the log4j system properly.

Changing SYSTEM "log4j.dtd" to SYSTEM "file://log4j.dtd" will work:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "file://log4j.dtd">

<log4j:configuration xmlns:log4j='http://jakarta.apache.org/log4j/'>
   ...
</log4j:configuration>

Xerces will work with both files. The problem occurs only with the XML 
parser in JDK 1.4 and 1.2.8 (proposed).


One solution is to support public DTD, as in

<!DOCTYPE log4j:configuration PUBLIC
    "-//Apache Software Foundation//DTD Log4j Configuration 1.2//EN"
    "http://jakarta.apache.org/log4j/dtds/log4j_1_2.dtd">

The entity resolver to support the above is trivial to write (thanks to 
Tomasz Stanczak). The problem with this approach is that existing config 
files would need to be modified which quite unacceptable.

It's pretty complicated...


--
Ceki 


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: log4j-dev-help@jakarta.apache.org


Mime
View raw message