2

为什么我会收到来自 Log4J 1.2.17 的警告?我正在尝试在我的 java 项目中使用 log4j,但我不断收到以下警告。有人可以告诉我为什么吗?

警告:

log4j:WARN Continuable parsing error 2 and column 87
log4j:WARN Document root element "log4j:configuration", must match DOCTYPE root "null".
log4j:WARN Continuable parsing error 2 and column 87
log4j:WARN Document is invalid: no grammar found.

我的 log4j.xml 文件:

<?xml version="1.0" encoding="UTF-8"?>
<log4j:configuration xmlns:log4j = "http://jakarta.apache.org/log4j/" debug = "false">
    <appender name = "FILE" class = "org.apache.log4j.RollingFileAppender">
        <param name = "File" value = "test.log"/>
        <param name = "MaxFileSize" value = "5MB"/>
        <param name = "MaxBackupIndex" value = "50"/>
        <layout class = "org.apache.log4j.PatternLayout">
            <param name = "ConversionPattern" value = "[%d{dd/MM/yy hh:mm:ss:sss z}] %5p %c{2}: %m%n"/>
        </layout>
    </appender>

    <appender name="console" class="org.apache.log4j.ConsoleAppender">
        <layout class="org.apache.log4j.PatternLayout">
            <param name="ConversionPattern" value="%d [%t] %-5p %c - %m%n" />
        </layout>
    </appender>


    <category name = "org.uftwf">
        <priority value = "debug"/>
    </category>

    <!-- 
    <category name = "org.apache.catalina">
        <priority value = "error"/>
    </category>


    <category name = "org.hibernate">
        <priority value = "debug"/>
    </category>

    <category name="org.hibernate.SQL"> 
        <priority value="TRACE"/>  
    </category> 

    <category name="org.hibernate.type"> 
         <priority  value="TRACE"/> 
     </category> 

     -->

    <root>
        <priority value = "warn"/>
        <appender-ref ref = "console"/>
    </root>
</log4j:configuration>

我知道这只是一个警告,但我想知道为什么我会得到它们并阻止它们来......谢谢

4

1 回答 1

5

你应该<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">在你的<log4j:configuration.

于 2012-10-02T17:44:26.430 回答