tags:

views:

364

answers:

2

i'm trying to convert my log4j.properties into log4j.xml because i need to use some of the filter feature. i'm getting a bunch of warning when i start the application, i'm not exactly sure how to solve them:

log4j:WARN Continuable parsing error 4 and column 69
log4j:WARN Attribute "threshold" for element type "log4j:configuration" has a default value and must be specified in a standalone document.
log4j:WARN Continuable parsing error 4 and column 69
log4j:WARN Attribute "debug" for element type "log4j:configuration" has a default value and must be specified in a standalone document.
log4j:WARN Continuable parsing error 4 and column 69
log4j:WARN Attribute "reset" for element type "log4j:configuration" has a default value and must be specified in a standalone document.
log4j:WARN Continuable parsing error 20 and column 23
log4j:WARN The content of element type "log4j:configuration" must match "(renderer*,appender*,plugin*,(category|logger)*,root?,(categoryFactory|loggerFactory)?)".
log4j:WARN Unrecognized element param

i'm just trying with a very simple log4j.xml file as well:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"&gt;
    <appender name="A1" class="org.apache.log4j.ConsoleAppender">
        <param name="Threshold" value="INFO"/>
        <layout class="org.apache.log4j.PatternLayout">
            <param name="ConversionPattern" value="%-5p | %d{MM-dd-yyyy HH:mm:ss.SSS} | %t | %c(%L) - %m%n"/>
        </layout>
    </appender>
    <root>
        <priority value="INFO"/>
        <appender-ref ref="A1"/>
    </root>
</log4j:configuration>

is there anything i missed here? thanks!

+1  A: 

As you suspect, removing the standalone="yes" attribute from the xml declaration will solve the problem. Standalone="yes" does some subtle things (here's the official spec). In this case the declaration is affecting how the validating xml parser used by log4j parses an xml document that refers to a dtd.

Removing that attribute from the declaration is probably correct, and should not meaningfully affect your log4j configuration.

Sean Reilly
+1  A: 

The standalone attribute, roughly speaking, declares that the information set is not affected by any content outside the document. However, in this case, it isn't true, because the attributes have default values that are specified in the external DTD.

erickson