سؤال

I am stumped with logback for a week already. My File's appender seems to log less than my Console's appender. My console's appender showed exception error when my Jetty goes up (due to myclass calls something into Jetty) yet those exception is not being shown in my File's appender. I have tried many different combination and still yield no change to my File's appender. Do I miss something big in logback ? please help.

<appender name="FILE"
    class="ch.qos.logback.core.rolling.RollingFileAppender">
    <encoder>
        <pattern>%d{HH:mm:ss z} [%thread] %-5level %logger{16}:%line- %msg%n%xException</pattern>
    </encoder>
    <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
        <!-- daily rollover period -->
        <fileNamePattern>${LOG_DIR}/MARI-%d.log</fileNamePattern>
        <!-- keep 7 days' worth of history -->
        <maxHistory>14</maxHistory>
    </rollingPolicy>
</appender>

<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
    <encoder>
        <pattern>%d{HH:mm:ss z} [%thread] %-5level %logger{16}:%line- %msg%n%xException</pattern>
    </encoder>
</appender>

<logger name="com.myclass" level="TRACE" additivity="false">
    <appender-ref ref="STDOUT"/> 
    <appender-ref ref="FILE"/>      
</logger>

<root level="ERROR"> 
    <appender-ref ref="STDOUT"/> 
    <appender-ref ref="FILE"/> 
</root> 

هل كانت مفيدة؟

المحلول

Found out from other stackoverflow's issue that I must surround the piece of code with try-catch and catch the generic Exception to get all the thrown exception.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top