如何打印logback内部错误和状态日志?

时间:2014-08-01 06:47:22

标签: java logging logback

我正在使用logback api并在我的类路径中有一个logback.xml,看起来像这样

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<configuration scan="true">

    <contextListener class="ch.qos.logback.classic.jul.LevelChangePropagator">
        <resetJUL>true</resetJUL> 
    </contextListener>
    <appender class="ch.qos.logback.core.ConsoleAppender" name="STDOUT">
        <encoder>
            <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern> 
        </encoder>
    </appender>
    <appender class="ch.qos.logback.core.rolling.RollingFileAppender" name="FILE">
        <file>/${path}/logs/application.log</file>
        <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
            <fileNamePattern>/${path}/logs/application.%i.log</fileNamePattern>
        </rollingPolicy>
        <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
            <maxFileSize>50MB</maxFileSize>
        </triggeringPolicy>
        <encoder>
            <pattern>%date %level [%thread] %logger{10} [%file:%line] %msg%n</pattern> 
        </encoder>
    </appender>

<!--  ~~~ PERFORMANCE TRACKING LOGGER CONFIGURATION (USING PERF4J) || END ||~~~ 
  --> 
    <logger name="com.nucleus">
        <level value="DEBUG"/> 
        <!-- <appender-ref ref="STDOUT" />  --> 
        <appender-ref ref="FILE"/> 
    </logger>
    <logger level="DEBUG" name="org.hibernate.transaction.JDBCTransaction"/> 
    <logger level="DEBUG" name="org.hibernate.jdbc.ConnectionManager"/> 
    <logger level="DEBUG" name="org.springframework.orm.jpa.JpaTransactionManager"/> 
    <!-- <root level="info">
        <appender-ref ref="FILE" />
    </root>  -->

</configuration>

现在我实施的回滚仅在生产环境中不起作用。我希望调试相同,因此想要为此logback api添加跟踪。任何人都可以建议我可能做错了什么或我该怎么做才能解决这个问题?

1 个答案:

答案 0 :(得分:1)

Logback 1.0.4开始,您可以使用系统属性-Dlogback.debug=true启用Logback设置的调试,以便调试配置。