.softgateway.example.3.5.23.source-code.logback-spring.xml Maven / Gradle / Ivy
<?xml version="1.0" encoding="UTF-8"?> <configuration debug="true"> <property name="LOG_FILE_NAME" value="demo-driver"/> <!--定义日志文件的存储地址 --> <springProfile name="!prod"> <property name="LOG_HOME" value="${user.home}/logs"/> </springProfile> <springProfile name="prod"> <property name="LOG_HOME" value="${LOG_HOME:-/data/logs}"/> </springProfile> <!--<property name="COLOR_PATTERN" value="%black(%contextName-) %red(%d{yyyy-MM-dd HH:mm:ss}) %green([%thread]) %highlight(%-5level) %boldMagenta( %replace(%caller{1}){'\t|Caller.{1}0|\r\n', ''})- %gray(%msg%xEx%n)" />--> <!-- 控制台输出 --> <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder"> <!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符 <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50}:%L - %msg%n</pattern>--> <!-- @formatter:off--> <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %highlight(%-5level) %logger{50}.%M:%L - %msg%n</pattern> <!-- @formatter:on--> <charset>UTF-8</charset> </encoder> </appender> <!-- 按照每天生成日志文件 --> <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> <file>${LOG_HOME}/${LOG_FILE_NAME}.log</file> <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"> <!--日志文件输出的文件名 --> <FileNamePattern>${LOG_HOME}/${LOG_FILE_NAME}-%d{yyyy-MM-dd}.%i.tar.gz</FileNamePattern> <!--日志文件保留天数 --> <MaxHistory>15</MaxHistory> <maxFileSize>100MB</maxFileSize> <totalSizeCap>2GB</totalSizeCap> <cleanHistoryOnStart>true</cleanHistoryOnStart> </rollingPolicy> <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder"> <!-- @formatter:off--> <!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符 --> <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50}:%L - %msg%n</pattern> <!-- @formatter:on--> <charset>UTF-8</charset> </encoder> </appender> <appender name="ERROR" class="ch.qos.logback.core.rolling.RollingFileAppender"> <file>${LOG_HOME}/${LOG_FILE_NAME}-error.log</file> <filter class="ch.qos.logback.classic.filter.ThresholdFilter"> <!--设置日志级别,过滤掉info日志,只输入error日志--> <level>ERROR</level> </filter> <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"> <!--日志文件输出的文件名 --> <FileNamePattern>${LOG_HOME}/${LOG_FILE_NAME}-error-%d{yyyy-MM-dd}.%i.tar.gz</FileNamePattern> <!--日志文件保留天数 --> <MaxHistory>15</MaxHistory> <maxFileSize>100MB</maxFileSize> <totalSizeCap>2GB</totalSizeCap> <cleanHistoryOnStart>true</cleanHistoryOnStart> </rollingPolicy> <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder"> <!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符 --> <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50}:%L - %msg%n</pattern> </encoder> </appender> <appender name="ASYNC_CONSOLE" class="ch.qos.logback.classic.AsyncAppender"> <!-- 拷贝堆栈信息, 默认false --> <includeCallerData>true</includeCallerData> <appender-ref ref="STDOUT"/> </appender> <!-- Spring日志级别控制 --> <logger name="org.springframework" level="warn"/> <!-- 日志输出级别 --> <springProfile name="!prod"> <logger name="org.apache.ibatis" level="TRACE"/> <logger name="com.ruoyi" level="TRACE"/> <logger name="java.sql.Connection" level="DEBUG"/> <logger name="java.sql.Statement" level="DEBUG"/> <logger name="java.sql.PreparedStatement" level="DEBUG"/> <root level="debug"> <appender-ref ref="ASYNC_CONSOLE"/> <appender-ref ref="FILE"/> <appender-ref ref="ERROR"/> </root> </springProfile> <springProfile name="prod"> <root level="INFO"> <appender-ref ref="FILE"/> <appender-ref ref="ERROR"/> </root> </springProfile> </configuration>
© 2015 - 2024 Weber Informatics LLC | Privacy Policy