<?xml version="1.0" encoding="UTF-8" ?>
<configuration >
<contextname>srb</contextname>
<property name = 'log.path' value="/Users/cherish/IdeaProjects/srb/service-core"/>
<!-- 定义变量:日志输出格式 颜色-->
<property name="CONSOLE_LOG_PATTERN"
value="%date{yyyy-MM-dd HH:mm:ss} | %highlight(%-5level) | %boldYellow(%thread) | %boldGreen(%logger) | %msg%n"/>
<!--文件日志格式-->
<property name="FILE_LOG_PATTERN"
value="%date{yyyy-MM-dd HH:mm:ss} | %highlight(%-5level) | %boldYellow(%thread) | %boldGreen(%logger) | %msg%n"/>
<!-- 控制台日志 -->
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
<encoder charset="UTF-8">
<pattern>${CONSOLE_LOG_PATTERN}</pattern>
</encoder>
</appender>
<!-- 滚动日志-->
<appender name="roll_file" class="ch.qos.logback.core.rolling.RollingFileAppender">
<!-- <file>${log.path}/roll_log.log</file>-->
<encoder charset="UTF-8">
<pattern>${FILE_LOG_PATTERN}</pattern>
</encoder>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>${log.path}/info/roll_log-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
<maxHistory>15</maxHistory>
<!-- 配置大小-->
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>1MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
</appender>
<!-- 文件日志-->
<appender name="file" class="ch.qos.logback.core.FileAppender">
<file>${log.path}/log.log</file>
<append>true</append>
<encoder charset="UTF-8">
<pattern>${FILE_LOG_PATTERN}</pattern>
</encoder>
</appender>
<!-- 日志记录器-->
<logger name="com.atguigu" level="INFO">
<appender-ref ref ="console"/>
<appender-ref ref ="file"/>
<appender-ref ref="roll_file"/>
</logger>
<!-- 多环境-->
<!-- <SpringProfile name="dev,test">-->
<!-- <logger name="com.atguigu" level="INFO">-->
<!-- <appender-ref ref ="console"/>-->
<!-- <appender-ref ref ="file"/>-->
<!-- </logger>-->
<!-- </SpringProfile>-->
<!-- 生产环境-->
<!-- <SpringProfile name="prod">-->
<!-- <logger name="com.atguigu" level="ERROR">-->
<!-- <appender-ref ref ="console"/>-->
<!-- <appender-ref ref ="file"/>-->
<!-- </logger>-->
<!-- </SpringProfile>-->
</configuration>
【无标题】
最新推荐文章于 2024-11-12 21:14:07 发布