如何从WildFly调试日志中删除Hibernate调试语句

时间:2016-01-04 11:26:15

标签: java hibernate wildfly wildfly-8

我正在使用WildFly登录调试模式,它显示了许多来自Hibernate的不必要的调试语句,我需要阻止它们。 这是我在standalone-full.xml中更改的内容。

<profile>
    <subsystem xmlns="urn:jboss:domain:logging:3.0">
        <console-handler name="CONSOLE">
            <level name="DEBUG"/>
            <formatter>
                <named-formatter name="COLOR-PATTERN"/>
            </formatter>
        </console-handler>
        <periodic-rotating-file-handler name="FILE" autoflush="true">
            <formatter>
                <named-formatter name="PATTERN"/>
            </formatter>
            <file relative-to="jboss.server.log.dir" path="server.log"/>
            <suffix value=".yyyy-MM-dd-HH"/>
            <append value="true"/>
        </periodic-rotating-file-handler>
        <logger category="com.arjuna">
            <level name="WARN"/>
        </logger>
        <logger category="org.apache.tomcat.util.modeler">
            <level name="WARN"/>
        </logger>
        <logger category="org.jboss.as.config">
            <level name="DEBUG"/>
        </logger>
        <logger category="sun.rmi">
            <level name="WARN"/>
        </logger>
        <logger category="jacorb">
            <level name="WARN"/>
        </logger>
        <logger category="jacorb.config">
            <level name="ERROR"/>
        </logger>
        <logger category="org.hibernate">
            <level name="INFO"/>
        </logger>
        <root-logger>
            <level name="DEBUG"/>
            <handlers>
                <handler name="CONSOLE"/>
                <handler name="FILE"/>
            </handlers>
        </root-logger>
        <formatter name="PATTERN">
            <pattern-formatter pattern="%d{yyyy-MM-dd HH:mm:ss,SSS} %-5p [%c] (%t) %s%e%n"/>
        </formatter>
        <formatter name="COLOR-PATTERN">
            <pattern-formatter pattern="%K{level}%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%e%n"/>
        </formatter>
    </subsystem>
</profile>

但它没有效果。

请建议我怎么做。

我的控制台充满了这样的陈述。

13:19:56,260 DEBUG [org.hibernate.engine.internal.TwoPhaseLoad] 
(DefaultQuartzScheduler_Worker-10) Resolving associations for [com.ecomm.pl4sms.persistence.entities.ErrorTable#10512575]
13:19:56,260 DEBUG [org.hibernate.engine.internal.TwoPhaseLoad] (DefaultQuartzScheduler_Worker-10) Done materializing entity [com.ecomm.pl4sms.persistence.entities.ErrorTable#10512575]
13:19:56,261 DEBUG [org.hibernate.engine.internal.TwoPhaseLoad] (DefaultQuartzScheduler_Worker-10) Resolving associations for [com.ecomm.pl4sms.persistence.entities.ErrorTable#10512576]
13:19:56,261 DEBUG [org.hibernate.engine.internal.TwoPhaseLoad] (DefaultQuartzScheduler_Worker-10) Done materializing entity [com.ecomm.pl4sms.persistence.entities.ErrorTable#10512576]
13:19:56,261 DEBUG [org.hibernate.engine.internal.TwoPhaseLoad] (DefaultQuartzScheduler_Worker-10) Resolving associations for [com.ecomm.pl4sms.persistence.entities.ErrorTable#10512577]
13:19:56,262 DEBUG [org.hibernate.engine.internal.TwoPhaseLoad] (DefaultQuartzScheduler_Worker-10) Done materializing entity [com.ecomm.pl4sms.persistence.entities.ErrorTable#10512577]
13:19:56,262 DEBUG [org.hibernate.engine.internal.TwoPhaseLoad] (DefaultQuartzScheduler_Worker-10) Resolving associations for [com.ecomm.pl4sms.persistence.entities.ErrorTable#10512578]

我想停止这些调试日志,只显示我在应用程序中添加的日志。

2 个答案:

答案 0 :(得分:1)

添加新的记录器条目:

<logger category="org.hibernate">
  <level name="INFO"/>
</logger>

这样只会记录INFO及以上级别的消息。

此外,从console-handler删除日志记录级别行。

答案 1 :(得分:0)

确保您的应用未使用Per-deployment Logging。如果是这种情况,则记录子系统配置不会产生任何影响。