- <!-- if debug set to true, context info always print
- otherwise the contex info will print when error occour -->
- <configuration scan="true" scanPeriod="60 seconds" debug="false">
- <appender name="stdout" class="ch.qos.logback.core.ConsoleAppender">
- <layout class="ch.qos.logback.classic.PatternLayout">
- <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{40} - %msg%n</pattern>
- </layout>
- </appender>
- <!-- 所有日志文件-->
- <appender name="AllLog" class="ch.qos.logback.core.rolling.RollingFileAppender">
- <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
- <fileNamePattern>log/abcchina/all/%d{yyyy-MM-dd}.log</fileNamePattern>
- <maxHistory>30</maxHistory>
- </rollingPolicy>
- <encoder>
- <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{40} - %msg%n</pattern>
- </encoder>
- </appender>
- <appender name="TaskLog" class="ch.qos.logback.core.rolling.RollingFileAppender">
- <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
- <fileNamePattern>log/abcchina/task/%d{yyyy-MM-dd}.log</fileNamePattern>
- <maxHistory>30</maxHistory>
- </rollingPolicy>
- <encoder>
- <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{40} - %msg%n</pattern>
- </encoder>
- </appender>
- <appender name="SendLog" class="ch.qos.logback.core.rolling.RollingFileAppender">
- <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
- <fileNamePattern>log/abcchina/send/%d{yyyy-MM-dd}.log</fileNamePattern>
- <maxHistory>30</maxHistory>
- </rollingPolicy>
- <encoder>
- <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{40} - %msg%n</pattern>
- </encoder>
- </appender>
- <!-- 为莫个包下的所有类指定Appender 这里也可以指定类名称例如:com.aa.bb.ClassName-->
- <logger name="com.aa.bb" >
- <appender-ref ref="TaskLog" />
- </logger>
- <logger name="com.aa.cc" >
- <appender-ref ref="SendLog" />
- </logger>
- <root level="INFO">
- <appender-ref ref="AllLog" />
- </root>
- </configuration>
logback 配置
最新推荐文章于 2021-07-21 10:26:21 发布