无法关闭/限制其中一个ApacheDS类的日志记录

时间:2016-08-31 11:38:33

标签: java logging configuration log4j2 apacheds

我使用以下log4j2配置来限制从一个ApacheDS类到ERROR和更小的日志记录。

<logger level="error" name="org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmIndex">
     <appender-ref ref="ARTFile" />
</logger>

此特定类的消息仍在DEBUG级别记录。以下包的类似设置有效。

org.apache.directory.server.core

请帮忙。

这是完整的配置。

<?xml version="1.0" encoding="UTF-8"?>
<configuration name="defaultConfiguration" strict="true" monitorInterval="5">
    <properties>
        <property name="patternlayout">%-5p %d{ISO8601} [%t][%4C][%L] - %m%n</property>
        <property name="filename">C:\\Releases\\RCL\\RLKSAdmin\\work\\rcladmin\\logs\\RLKS_ART.log</property>
        <property name="filenamePattern">C:\\Releases\\RCL\\RLKSAdmin\\work\\rcladmin\\logs\\RLKS_ART_%i.log</property>
    </properties>
    <appenders>
        <RollingFile name="ARTFile" fileName="${filename}" filePattern="${filenamePattern}" append="true">
            <PatternLayout pattern="${patternlayout}" charset="UTF-8" />
            <Policies>
                <SizeBasedTriggeringPolicy size="3 MB" />
            </Policies>
            <DefaultRolloverStrategy max="5" />
        </RollingFile>
    </appenders>
    <loggers>
        <root level="trace">
            <appender-ref ref="ARTFile" />
        </root>
        <logger level="error" name="org.springframework.core">
            <appender-ref ref="ARTFile" />
        </logger>
        <logger level="error" name="org.springframework.beans">
            <appender-ref ref="ARTFile" />
        </logger>
        <logger level="error" name="org.springframework.context">
            <appender-ref ref="ARTFile" />
        </logger>
        <logger level="error" name="org.springframework.web">
            <appender-ref ref="ARTFile" />
        </logger>
        <logger level="error" name="org.springframework.security">
            <appender-ref ref="ARTFile" />
        </logger>
        <logger level="error" name="org.springframework.ldap">
            <appender-ref ref="ARTFile" />
        </logger>
        <logger level="error" name="org.springframework.jndi">
            <appender-ref ref="ARTFile" />
        </logger>
        <logger level="error" name="org.springframework.validation">
            <appender-ref ref="ARTFile" />
        </logger>
        <logger level="error" name="org.springframework.ui">
            <appender-ref ref="ARTFile" />
        </logger>
        <logger level="error" name="org.springframework.util">
            <appender-ref ref="ARTFile" />
        </logger>
        <logger level="error" name="org.apache.directory.server.schema">
            <appender-ref ref="ARTFile" />
        </logger>
        <logger level="error" name="org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmIndex"/>
        <logger level="error" name="org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmTable"/>
        <logger level="error" name="org.apache.directory.server.core">
            <appender-ref ref="ARTFile" />
        </logger>
        <logger level="error" name="org.apache.directory.server.core.partition">
            <appender-ref ref="ARTFile" />
        </logger>
        <logger level="error" name="org.apache.directory.server.protocol">
            <appender-ref ref="ARTFile" />
        </logger>
        <logger level="error" name="org.apache.directory.shared">
            <appender-ref ref="ARTFile" />
        </logger>
    </loggers>
</configuration>

1 个答案:

答案 0 :(得分:1)

如果您的目标是限制日志级别,最好不要指定appender-ref:这种限制适用于根记录器和所有关联的appender。在您显示的配置代码段中,限制仅适用于“ARTFile”appender。