123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- <?xml version="1.0" encoding="UTF-8"?>
- <configuration>
- <include resource="org/springframework/boot/logging/logback/base.xml" />
- <logger name="org.springframework.web" level="INFO"/>
- <logger name="org.springboot.sample" level="TRACE" />
- <!-- 开发、测试环境 -->
- <springProfile name="dev,test">
- <logger name="org.springframework.web" level="INFO"/>
- <logger name="org.springboot.sample" level="INFO" />
- <logger name="com.xjrsoft" level="DEBUG" />
- </springProfile>
- <!-- 生产环境 -->
- <springProfile name="prod">
- <logger name="org.springframework.web" level="ERROR"/>
- <logger name="org.springboot.sample" level="ERROR" />
- <logger name="com.xjrsoft" level="ERROR" />
- </springProfile>
- <!-- 日志存放路径 -->
- <property name="log.path" value="./logs" />
- <!-- 日志输出格式 -->
- <property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n" />
- <!-- 控制台输出 -->
- <appender name="console" class="ch.qos.logback.core.ConsoleAppender">
- <encoder>
- <pattern>${log.pattern}</pattern>
- </encoder>
- </appender>
- <!-- 系统日志输出 -->
- <appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
- <file>${log.path}/sys-info.log</file>
- <!-- 循环政策:基于时间创建日志文件 -->
- <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
- <!-- 日志文件名格式 -->
- <fileNamePattern>${log.path}/sys-info.%d{yyyy-MM-dd}.log</fileNamePattern>
- <!-- 日志最大的历史 60天 -->
- <maxHistory>60</maxHistory>
- </rollingPolicy>
- <encoder>
- <pattern>${log.pattern}</pattern>
- </encoder>
- <filter class="ch.qos.logback.classic.filter.LevelFilter">
- <!-- 过滤的级别 -->
- <level>INFO</level>
- <!-- 匹配时的操作:接收(记录) -->
- <onMatch>ACCEPT</onMatch>
- <!-- 不匹配时的操作:拒绝(不记录) -->
- <onMismatch>DENY</onMismatch>
- </filter>
- </appender>
- <appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
- <file>${log.path}/sys-error.log</file>
- <!-- 循环政策:基于时间创建日志文件 -->
- <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
- <!-- 日志文件名格式 -->
- <fileNamePattern>${log.path}/sys-error.%d{yyyy-MM-dd}.log</fileNamePattern>
- <!-- 日志最大的历史 60天 -->
- <maxHistory>60</maxHistory>
- </rollingPolicy>
- <encoder>
- <pattern>${log.pattern}</pattern>
- </encoder>
- <filter class="ch.qos.logback.classic.filter.LevelFilter">
- <!-- 过滤的级别 -->
- <level>ERROR</level>
- <!-- 匹配时的操作:接收(记录) -->
- <onMatch>ACCEPT</onMatch>
- <!-- 不匹配时的操作:拒绝(不记录) -->
- <onMismatch>DENY</onMismatch>
- </filter>
- </appender>
- <!-- 用户访问日志输出 -->
- <appender name="sys-user" class="ch.qos.logback.core.rolling.RollingFileAppender">
- <file>${log.path}/sys-user.log</file>
- <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
- <!-- 按天回滚 daily -->
- <fileNamePattern>${log.path}/sys-user.%d{yyyy-MM-dd}.log</fileNamePattern>
- <!-- 日志最大的历史 60天 -->
- <maxHistory>60</maxHistory>
- </rollingPolicy>
- <encoder>
- <pattern>${log.pattern}</pattern>
- </encoder>
- </appender>
- <!-- 系统模块日志级别控制 -->
- <logger name="com.xjrsoft" level="info" />
- <!-- Spring日志级别控制 -->
- <logger name="org.springframework" level="info" />
- <root level="info">
- <appender-ref ref="console" />
- </root>
- <!--系统操作日志-->
- <root level="info">
- <appender-ref ref="file_info" />
- <appender-ref ref="file_error" />
- </root>
- <!--系统用户操作日志-->
- <logger name="sys-user" level="info">
- <appender-ref ref="sys-user"/>
- </logger>
- </configuration>
|