Log levels in SLF4J, LOG4J and Java default logging

As a java developer, you are most likely using one of the following libraries to log messages:
SLF4J
LOG4J
or Default Java Logging

The following table depicts the log levels supported by each framework, ranked from highest to lowest.

SLF4JLOG4JJava Logging API
ERRORFATALSEVERE
WARNERRORWARNING
INFOWARNINFO
DEBUGINFOCONFIG
TRACEDEBUGFINE
TRACEFINER
FINEST

Adding Rolling Logs capability to Spring Boot

Introduction

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 application.properties 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:

logging.level.org.springframework.web=DEBUG
logging.level.org.hibernate=ERROR
logging:
  file: log/application.log
  level:
    ROOT: INFO
    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

logging:
  config: classpath:logback-local.xml

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

<configuration>
 <include resource="org/springframework/boot/logging/logback/defaults.xml"/>
 <springProperty scope="context" name="springAppName" source="spring.application.name"/>
 <!-- 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">
 <file>log/application.log</file>
 <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
 <!-- daily rollover -->
 <fileNamePattern>application.%d{yyyy-MM-dd}.log</fileNamePattern>

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

 </rollingPolicy>

 <encoder>
 <pattern>${CONSOLE_LOG_PATTERN}}</pattern>
 </encoder>
 </appender>
 <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
 <encoder>
 <pattern>${CONSOLE_LOG_PATTERN}</pattern>
 </encoder>
 </appender>
 <logger name="org.springframework.web.filter.CommonsRequestLoggingFilter">
 <appender-ref ref="FILE"/>
 </logger>
 <logger name="com.fullstacktrace.net">
 <appender-ref ref="FILE"/>
 </logger>
 <root level="INFO">
 <appender-ref ref="STDOUT"/>
 </root>

</configuration>

You can find more advanced logback setttings here

References

1. Spring Boot Docs
2. LogBack Docs