logback.xml configuration with STDOUT and Daily Rolling FILE appender


/ Published in: Java
Save to your folder(s)

ch.qos.logback
logback-classic
0.9.8


Copy this code and paste it in your HTML
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <configuration>
  3. <appender name="STDOUT"
  4. class="ch.qos.logback.core.ConsoleAppender">
  5. <layout class="ch.qos.logback.classic.PatternLayout">
  6. <pattern>%-4relative [%thread] %-5level %class - %msg%n</pattern>
  7. </layout>
  8. </appender>
  9.  
  10. <!--Basic file appender<appender name="FILE"
  11. class="ch.qos.logback.core.FileAppender">
  12. <layout class="ch.qos.logback.classic.PatternLayout">
  13. <pattern>%-4relative [%thread] %-5level %class - %msg%n</pattern>
  14. </layout>
  15. <File>sample-log.txt</File>
  16. </appender>-->
  17.  
  18. <!--Daily rolling file appender -->
  19. <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
  20. <File>logFile.log</File>
  21. <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
  22. <FileNamePattern>logFile.%d{yyyy-MM-dd}.log</FileNamePattern>
  23. </rollingPolicy>
  24.  
  25. <layout class="ch.qos.logback.classic.PatternLayout">
  26. <Pattern>%-4relative [%thread] %-5level %logger{35} - %msg%n</Pattern>
  27. </layout>
  28. </appender>
  29.  
  30.  
  31. <logger name="deng.mysimpleapp">
  32. <level value="debug" />
  33. </logger>
  34.  
  35. <root>
  36. <level value="error" />
  37. <appender-ref ref="STDOUT" />
  38. <appender-ref ref="FILE" />
  39. </root>
  40. </configuration>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.