Appenders包含无效的元素或属性“xi:include”

时间:2015-11-14 08:31:04

标签: xml logging log4j log4j2

附加器/ console.xml

<?xml version="1.0" encoding="UTF-8" ?>
<Console name="Console" target="SYSTEM_OUT">
    <PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss} log4j2-dev %5p %c{1}:%L - %m%n"/>
</Console>

log4j2.dev.xml

<?xml version="1.0" encoding="UTF-8" ?>
<Configuration xmlns:xi="http://www.w3.org/2001/XInclude">
    <Appenders>
        <xi:include href="appender/console.xml" />
    </Appenders>

    <Loggers>
        <Root level="INFO">
            <AppenderRef ref="Console"/>
        </Root>
    </Loggers>
</Configuration>

我编写了一个使用xmlns:xi的简单log4j2配置(上图)。错误输出是

ERROR StatusLogger No log4j2 configuration file found. Using default configuration: logging only errors to the console.
2015-11-14 16:19:34,348 ERROR Appenders contains an invalid element or attribute "xi:include"
2015-11-14 16:19:34,376 ERROR Unable to locate appender Console for logger 

但是,如果我合并appender/console.xmllog4j2.dev.xml并使用合并后的<?xml version="1.0" encoding="UTF-8" ?> <configuration> <Appenders> <Console name="Console" target="SYSTEM_OUT"> <PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss} log4j2-dev %5p %c{1}:%L - %m%n"/> </Console> </Appenders> <Loggers> <Root level="INFO"> <AppenderRef ref="Console"/> </Root> </Loggers> </configuration> 。错误消失了。

{{1}}

我google了很多。但找不到解决方案来解决它。请帮忙。

0 个答案:

没有答案