0

我正在开发一个 Spring WebFlow 项目。我无法阻止 log4j 打印调试语句。有人可以告诉我如何让它停止在控制台上放置调试语句并记录。

当我的服务器启动时,我看到了这个警告:

log4j:WARN Continuable parsing error 42 and column 11
log4j:WARN The content of element type "logger" must match "(level?,appender-ref*)".

下面是我的 log4j.xml 文件:

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

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

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


    <appender name="logfile" class="org.apache.log4j.FileAppender">
        <param name="File" value="logs/disater_relief.log" />
        <layout class="org.apache.log4j.PatternLayout">
            <param name="ConversionPattern" value="%d %-5p %c - %m%n" />
        </layout>
    </appender>


    <appender name="rollinglogfile" class="org.apache.log4j.RollingFileAppender">
        <param name="file" value="logs/school_visit.log" />
        <param name="immediateFlush" value="true" />
        <param name="append" value="true" />
        <param name="maxFileSize" value="1MB" />
        <param name="maxBackupIndex" value="3" />

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

    </appender>

    <appender name="dailyrollinglogfile" class="org.apache.log4j.DailyRollingFileAppender">
        <param name="file" value="./logs/school_visit.log" />
        <param name="immediateFlush" value="true" />
        <param name="append" value="true" />
        <param name="datePattern" value=" '.' yyyy-MM-dd " />
        <layout class="org.apache.log4j.PatternLayout">
            <param name="ConversionPattern" value="%d %-5p %c - %m%n" />
        </layout>

    </appender>

    <appender name="email" class="org.apache.log4j.net.SMTPAppender">
        <param name="BufferSize" value="512" />
        <param name="SMTPHost" value="xxx" />
        <param name="From" value="xx" />
        <param name="To" value="xx" />
        <param name="Subject" value="School Visit Web - SYSTEM ERROR" />

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

        <filter class="org.apache.log4j.varia.LevelRangeFilter">
            <param name="LevelMin" value="ERROR" />
            <param name="LevelMax" value="FATAL" />
        </filter>
    </appender>

    <root>
        <priority value="WARN" />
        <appender-ref ref="email" />
        <appender-ref ref="console" />
        <appender-ref ref="dailyrollinglogfile" />
    </root>
</log4j:configuration>
4

1 回答 1

1

这只是一个 log4j 问题。这似乎<priority>不是 logger 元素的有效子元素<root>。相反,你应该有<level>

于 2012-09-07T13:44:07.637 回答