Skip to content

Instantly share code, notes, and snippets.

@middlesphere
Created December 10, 2017 21:50
Show Gist options
  • Save middlesphere/8bae7e07475f06f4e010d40c3ba712a3 to your computer and use it in GitHub Desktop.
Save middlesphere/8bae7e07475f06f4e010d40c3ba712a3 to your computer and use it in GitHub Desktop.
logback.xml example
<configuration debug="false" scan="true" scanPeriod="30 seconds">
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
<!-- <pattern>{ :time #inst "%d{yyyy-MM-dd'T'HH:mm:ss.SSS'Z'}", :host "${HOSTNAME}", :level "%level", :logger "%logger{36}", :msg %msg}%n</pattern> -->
</encoder>
</appender>
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>test.log</file>
<append>true</append>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- rollover daily -->
<fileNamePattern>mylog-%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
<maxHistory>10</maxHistory>
<timeBasedFileNamingAndTriggeringPolicy
class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<!-- or whenever the file size reaches 100MB -->
<maxFileSize>100MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
<encoder>
<pattern>{ :time #inst "%d{yyyy-MM-dd'T'HH:mm:ss.SSS'Z'}", :host "${HOSTNAME}", :level "%level", :logger "%logger{36}", :msg %msg }%n</pattern>
</encoder>
</appender>
<logger name="test01.core" level="INFO"/>
<root level="ERROR">
<appender-ref ref="CONSOLE"/>
<appender-ref ref="FILE"/>
</root>
</configuration>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment