Skip to content

Instantly share code, notes, and snippets.

@jotajr
Last active April 3, 2023 17:53
Show Gist options
  • Save jotajr/c3c3a95b16fd3fea6ea042494ff59aee to your computer and use it in GitHub Desktop.
Save jotajr/c3c3a95b16fd3fea6ea042494ff59aee to your computer and use it in GitHub Desktop.
Sample of logback configuration file for using with Spring Boot
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appender name="Console"
class="ch.qos.logback.core.ConsoleAppender">
<layout class="ch.qos.logback.classic.PatternLayout">
<pattern>[%d{yyyy/MM/dd HH:mm:ss:SSS}] %yellow([%thread]) %highlight(%-5level) [%cyan(%logger{15}):%green(%M):%magenta(%L)] - %m%n</pattern>
</layout>
</appender>
<appender name="RollingFile"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>log/log_file_name.log</file>
<encoder
class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<Pattern>[%X{process_id}][%thread][%d{yyyy/MM/dd HH:mm:ss:SSS}] %-5p [%logger{15}:%M:%L] - %m%n</Pattern>
</encoder>
<rollingPolicy
class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- rollover daily and when the file reaches 10 MegaBytes -->
<fileNamePattern>log/archived/log_file_name-%d{yyyy-MM-dd}.%i.log
</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy
class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>10MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
</appender>
<root level="info">
<appender-ref ref="RollingFile" />
<appender-ref ref="Console" />
</root>
<logger name="br.com.norteware" level="info" additivity="false">
<appender-ref ref="RollingFile" />
<appender-ref ref="Console" />
</logger>
</configuration>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment