Setting Up Logback in Maven Project

POM Dependencies

Version numbers might need to be adjusted to the latest.


  1.1.2



  ch.qos.logback
  logback-core
  ${logback-version}


  ch.qos.logback
  logback-classic
  ${logback-version}


  org.slf4j
  slf4j-api
  1.7.7

logback.xml Configuration File

This config just spits out log into stdout in a pretty standard log format. Place this on src/main/resources





    
      %d{YYYY-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
    
  


    
  

Size-capped File Log

Add this configuration to log to file. In this settings the log file will be rolled over daily and 30 days worth of history are saved. Anything older than that will be deleted to avoid eating up all disk spaces.


  MyApp.log
  
    
    MyAppp.%d{yyyy-MM-dd}.log
    
    30
  
  
    %d{YYYY-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
  



  
  

Leave a Reply