First you define the appender, and then you define a Logger node that references the appender you just defined. The Logger node has the following three properties, which are described below.

The complete example is as follows:

<appender name="interceptorTimeFileOutput" class="ch.qos.logback.core.rolling.RollingFileAppender"> <! <File>${LOG_HOME}/xx/interceptor.log</File> <! - file scroll mode - > < rollingPolicy class = "ch. Qos. Logback. Core. Rolling. TimeBasedRollingPolicy" > <! <FileNamePattern>${LOG_HOME}/xx/interceptor.%d{YYYY-MM-DD}.%i.log.gz</FileNamePattern> <! MaxHistory </MaxHistory> <! - according to the size of the partition on the same day - > < timeBasedFileNamingAndTriggeringPolicy class = "ch. Qos. Logback. Core. Rolling. SizeAndTimeBasedFNATP" > <maxFileSize>10KB</maxFileSize> </timeBasedFileNamingAndTriggeringPolicy> </rollingPolicy> <! Output format -- - > < encoder class = "ch. Qos. Logback. Classic. Encoder. PatternLayoutEncoder" > <! Format output: %d indicates the date, %thread indicates the thread name, %-5level indicates the level from the left 5 character width % MSG: -> <pattern>%d{YYYY-MM-DD HH: MM :ss.SSS} [%thread] %-5level % Logger {50} - % MSG %n</pattern> <! < <charset>UTF-8</charset> </encoder> </appender> < Logger name="com.xxx.xx" level="INFO" additivity="false" > <appender-ref ref="interceptorTimeFileOutput"/> </logger>Copy the code

Running results:


[35] Logback additivity=”false” with root