【发布时间】:2019-01-04 07:25:53
【问题描述】:
我无法让我的 log4j2.xml 文件符合架构。没有架构规范,我没有任何错误,但有了它,我得到了:
cvc-complex-type.2.4.d: Invalid content was found starting with element 'File'. No child element is expected at
this point.
cvc-complex-type.2.4.d: Invalid content was found starting with element 'Logger'. No child element is expected
at this point.
在没有架构的情况下,日志记录工作正常,但 Eclipse 警告说它丢失了,所以我想把它放在适当的位置。这是我正在使用的 log4j2.xml 文件:
<?xml version="1.0" encoding="UTF-8"?>
<Configuration strict="true"
xmlns="http://logging.apache.org/log4j/2.0/config"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://logging.apache.org/log4j/2.0/config
https://raw.githubusercontent.com/apache/logging-log4j2/log4j-2.11.1/log4j-core/src/main/resources/Log4j-config.xsd">
<Appenders>
<Console name="console" target="SYSTEM_OUT">
<PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss z} %-5p %-5level - %msg%n"/>
</Console>
<File name="file" fileName="mylogfile.log" append="true">
<PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss z} %-5p %-5level - %msg%n"/>
</File >
</Appenders>
<Loggers>
<Root level="DEBUG">
<AppenderRef ref="console"/>
<AppenderRef ref="file"/>
</Root>
<Logger name="org.apache.http" level="WARN" additivity="false">
<AppenderRef ref="console"/>
<AppenderRef ref="file"/>
</Logger>
<Logger name="net.authorize.util" level="WARN" additivity="false">
<AppenderRef ref="console"/>
<AppenderRef ref="file"/>
</Logger>
<Logger name="net.authorize.api" level="WARN" additivity="false">
<AppenderRef ref="console"/>
<AppenderRef ref="file"/>
</Logger>
</Loggers>
</Configuration>
【问题讨论】: