Adding Rolling Logs capability to Spring Boot


Spring Boot has LoggingSystem abstraction, which means you can use any Logging library you prefer.
Due to this constraint, Spring Boot only provides basic properties that can be written in your or application.yml files.

Spring Boot allows you to set the logging levels and location of log (file or console) from your configuration file. For example:
  file: log/application.log
    org.springframework.web.filter.CommonsRequestLoggingFilter: DEBUG
    com.fullstacktrace.logDemo: DEBUG

Rolling Logs

To configure more advanced or fine-grained settings for logging, you must provide it in native configuration format.
Spring Boot will pick up the native configuration from the default location. For logback that location is classpath: logback.xml . You can also overwrite this location by setting the logging.config property

  config: classpath:logback-local.xml

To set Rolling Logs, you need to provide the setttings in logback.xml file:

 <include resource="org/springframework/boot/logging/logback/defaults.xml"/>
 <springProperty scope="context" name="springAppName" source=""/>
 <!-- You can override this to have a custom pattern -->
 <property name="CONSOLE_LOG_PATTERN"
 value="%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(${PID:- }){magenta} %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}"/>

 <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
 <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
 <!-- daily rollover -->

 <!-- keep 90 days' worth of history capped at 3GB total size -->


 <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
 <logger name="org.springframework.web.filter.CommonsRequestLoggingFilter">
 <appender-ref ref="FILE"/>
 <logger name="">
 <appender-ref ref="FILE"/>
 <root level="INFO">
 <appender-ref ref="STDOUT"/>


You can find more advanced logback setttings here


1. Spring Boot Docs
2. LogBack Docs