framework.kalvan-core.1.2.source-code.logback-spring.xml Maven / Gradle / Ivy
<configuration debug="false" encoding="UTF-8"> <springProperty scope="context" name="logback.logPath" source="logback.logPath"/> <springProperty scope="context" name="logback.rootLoggerLevel" source="logback.rootLoggerLevel"/> <springProperty scope="context" name="logback.maxFileSize" source="logback.maxFileSize"/> <!-- 配置属性由System.setProperty注入实现动态配置,这样可以在项目中不用配置该文件只需配置日志参数便可使用,做为默板使用 --> <!-- <property name="logback.logPath" value="/logs/home-portal"/>--> <!-- <property name="logback.rootLoggerLevel" value="DEBUG"/>--> <!-- <property name="logback.maxFileSize" value="500MB"/>--> <property name="logback.encoding" value="UTF-8"/> <!-- 统一日志格式输出用|分隔方便 elk日志工具收集处理 ,默认日志格式是 时间|级别|日志戳|代码路径|扩展json(收集图表数据,无则域留空)|脱敏后日志内容 --> <property name="logback.pattern" value="%date{yyyy-MM-dd HH:mm:ss.SSS}|%-5level|%logTraceId|%class.%method:%line|%extJson|%sensitiveMsg%n"/> <!-- 错误日志输出格式, 默认日志格式是 时间|级别|日志戳|代码路径|扩展json(收集图表数据,无则域留空)|脱敏后日志内容 --> <property name="logback.pattern.error" value="%date{yyyy-MM-dd HH:mm:ss.SSS}|%-5level|%logTraceId|%class.%method:%line|%extJson|%sensitiveMsg%n"/> <!-- 设置控制台日志 --> <appender name="STDOUT" class="com.kalvan.log.logback.appender.ExtConsoleAppender"> <encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder"> <layout class="com.kalvan.log.logback.layout.ExtLayout"> <pattern>${logback.pattern}</pattern> </layout> </encoder> </appender> <appender name="DEBUG_FILE" class="com.kalvan.log.logback.appender.ExtDebugRollingFileAppender"> <file>${logback.logPath}/debug.log</file> <!-- see https://logback.qos.ch/manual/filters.html --> <filter class="ch.qos.logback.classic.filter.LevelFilter"> <level>DEBUG</level> </filter> <!-- see https://logback.qos.ch/manual/appenders.html#SizeAndTimeBasedFNATP --> <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"> <fileNamePattern>${logback.logPath}/debug.%d{yyyyMMdd}.%i.log </fileNamePattern> <!-- 文件最大、保留30天、总保留3GB日志文件 --> <maxFileSize>${logback.maxFileSize}</maxFileSize> <maxHistory>30</maxHistory> <totalSizeCap>10GB</totalSizeCap> </rollingPolicy> <encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder"> <!-- see https://logback.qos.ch/manual/layouts.html --> <layout class="com.kalvan.log.logback.layout.ExtLayout"> <pattern>${logback.pattern.error}</pattern> </layout> </encoder> </appender> <appender name="INFO_FILE" class="com.kalvan.log.logback.appender.ExtRollingFileAppender"> <file>${logback.logPath}/info.log</file> <filter class="ch.qos.logback.classic.filter.ThresholdFilter"> <level>INFO</level> </filter> <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"> <fileNamePattern>${logback.logPath}/info.%d{yyyyMMdd}.%i.log </fileNamePattern> <maxFileSize>${logback.maxFileSize}</maxFileSize> </rollingPolicy> <encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder"> <layout class="com.kalvan.log.logback.layout.ExtLayout"> <pattern>${logback.pattern}</pattern> </layout> </encoder> </appender> <appender name="ERROR_FILE" class="com.kalvan.log.logback.appender.ExtRollingFileAppender"> <file>${logback.logPath}/error.log</file> <filter class="ch.qos.logback.classic.filter.ThresholdFilter"> <level>WARN</level> </filter> <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"> <fileNamePattern>${logback.logPath}/error.%d{yyyyMMdd}.%i.log </fileNamePattern> <maxFileSize>${logback.maxFileSize}</maxFileSize> </rollingPolicy> <encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder"> <layout class="com.kalvan.log.logback.layout.ExtLayout"> <pattern>${logback.pattern.error}</pattern> </layout> </encoder> </appender> <appender name="MSG_FILE" class="com.kalvan.log.logback.appender.ExtRollingFileAppender"> <file>${logback.logPath}/msg.log</file> <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"> <fileNamePattern>${logback.logPath}/msg.%d{yyyyMMdd}.%i.log </fileNamePattern> <maxFileSize>${logback.maxFileSize}</maxFileSize> </rollingPolicy> <encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder"> <layout class="com.kalvan.log.logback.layout.ExtLayout"> <pattern>${logback.pattern}</pattern> </layout> </encoder> </appender> <!-- 用来设置某一个包或者某一个类的日志打印级别 --> <logger name="org.springframework" level="warn"/> <logger name="org.apache" level="info"/> <logger name="org.aspectj.weaver" level="warn"/> <logger name="org.hibernate" level="OFF"/> <logger name="com.mchange" level="OFF"/> <logger name="java.sql.Connection" level="debug"/> <logger name="java.sql.Statement" level="debug"/> <logger name="java.sql.ResultSet" level="debug"/> <logger name="java.sql.PreparedStatement" level="debug"/> <logger name="org.apache.commons.httpclient" level="OFF"/> <logger name="org.apache.commons.httpclient.Wire" level="OFF"/> <logger name="httpclient" level="error"/> <logger name="httpclient.wire.content" level="error"/> <logger name="httpclient.wire.header" level="error"/> <logger name="org.apache.dubbo" level="ERROR"/> <logger name="org.apache.zookeeper" level="ERROR"/> <logger name="com.netflix" level="ERROR"/> <logger name="com.alibaba" level="ERROR"/> <logger name="msg" additivity="false"> <appender-ref ref="MSG_FILE"/> <appender-ref ref="INFO_FILE"/> <!-- 控制台日志放在最后解析 --> <appender-ref ref="STDOUT"/> </logger> <root level="${logback.rootLoggerLevel}"> <appender-ref ref="DEBUG_FILE"/> <appender-ref ref="INFO_FILE"/> <appender-ref ref="ERROR_FILE"/> <!-- 控制台日志放在最后解析 --> <appender-ref ref="STDOUT"/> </root> </configuration>