0

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> 

EdisonCh
  • 13
  • 1
  • 7
  • I just found out how to get around this particular problem. The key is to manually catch all Exception in my own codes because there are no logging framework would be able to catch RunTimeException without having that defined somewhere in the code (try-catch Exception) Thanks to http://logback.10977.n7.nabble.com/Logging-uncaught-exceptions-that-go-to-server-log-td3650.html – EdisonCh May 03 '14 at 05:06
  • possible duplicate of [How to grab uncaught exceptions in a Java servlet web application](http://stackoverflow.com/questions/7410414/how-to-grab-uncaught-exceptions-in-a-java-servlet-web-application) – Scott Solmer May 23 '14 at 11:54

1 Answers1

0

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.

EdisonCh
  • 13
  • 1
  • 7