Browse Source

#日志限制

zhongwei
yang_shj 1 year ago
parent
commit
353f04009e
  1. 127
      hzims-service/operational/src/main/resources/log/logback-dev.xml
  2. 127
      hzims-service/operational/src/main/resources/log/logback-prod.xml
  3. 127
      hzims-service/operational/src/main/resources/log/logback-test.xml

127
hzims-service/operational/src/main/resources/log/logback-dev.xml

@ -0,0 +1,127 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="60 seconds">
<!-- 自定义参数监听 -->
<contextListener class="org.springblade.core.log.listener.LoggerStartupListener"/>
<!-- 彩色日志依赖的渲染类 -->
<conversionRule conversionWord="clr" converterClass="org.springframework.boot.logging.logback.ColorConverter"/>
<conversionRule conversionWord="wex"
converterClass="org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter"/>
<conversionRule conversionWord="wEx"
converterClass="org.springframework.boot.logging.logback.ExtendedWhitespaceThrowableProxyConverter"/>
<!-- 彩色日志格式 -->
<property name="CONSOLE_LOG_PATTERN"
value="${CONSOLE_LOG_PATTERN:-%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(${PID:- }){magenta} %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}}"/>
<!-- 控制台输出 -->
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>${CONSOLE_LOG_PATTERN}</pattern>
<charset>utf8</charset>
</encoder>
</appender>
<!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符 -->
<property name="log.pattern"
value="[%d{yyyy-MM-dd HH:mm:ss.SSS}] [%t] [%X{traceId}] %-5level %logger{50} - %msg%n"/>
<!-- 生成日志文件 -->
<appender name="INFO" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>log/info.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<!-- 日志文件输出的文件名 -->
<fileNamePattern>log/info/info-%d{yyyy-MM-dd_HH}.%i.log</fileNamePattern>
<!--设置保存10天 一天24个文件,一小时生成一个-->
<MaxHistory>240</MaxHistory>
<!--给定日志文件大小,超过指定的大小就新建一个日志文件-->
<maxFileSize>20MB</maxFileSize>
<totalSizeCap>10GB</totalSizeCap> <!-- 总日志大小 -->
<cleanHistoryOnStart>true</cleanHistoryOnStart>
</rollingPolicy>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<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="ERROR" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>log/error.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<!-- 日志文件输出的文件名 -->
<fileNamePattern>log/error/error-%d{yyyy-MM-dd_HH}.%i.log</fileNamePattern>
<!--设置保存15天 一天24个文件,一小时生成一个-->
<MaxHistory>360</MaxHistory>
<!--给定日志文件大小,超过指定的大小就新建一个日志文件-->
<maxFileSize>20MB</maxFileSize>
<totalSizeCap>10GB</totalSizeCap> <!-- 总日志大小 -->
<cleanHistoryOnStart>true</cleanHistoryOnStart>
</rollingPolicy>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>${log.pattern}</pattern>
</encoder>
<!-- 打印日志级别 -->
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>ERROR</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<!-- 日志输出级别 -->
<root level="ERROR">
<appender-ref ref="STDOUT"/>
<!--<appender-ref ref="INFO"/>-->
<appender-ref ref="ERROR"/>
</root>
<logger name="net.sf.ehcache" level="ERROR"/>
<logger name="druid.sql" level="ERROR"/>
<!-- MyBatis log configure -->
<logger name="com.apache.ibatis" level="ERROR"/>
<logger name="org.mybatis.spring" level="ERROR"/>
<logger name="java.sql.Connection" level="ERROR"/>
<logger name="java.sql.Statement" level="ERROR"/>
<logger name="java.sql.PreparedStatement" level="ERROR"/>
<!-- 减少部分debug日志 -->
<logger name="druid.sql" level="ERROR"/>
<logger name="org.apache.shiro" level="ERROR"/>
<logger name="org.mybatis.spring" level="ERROR"/>
<logger name="org.springframework" level="ERROR"/>
<logger name="org.springframework.context" level="ERROR"/>
<logger name="org.springframework.beans" level="ERROR"/>
<logger name="com.baomidou.mybatisplus" level="ERROR"/>
<logger name="org.apache.ibatis.io" level="ERROR"/>
<logger name="org.apache.velocity" level="ERROR"/>
<logger name="org.eclipse.jetty" level="ERROR"/>
<logger name="io.undertow" level="ERROR"/>
<logger name="org.xnio.nio" level="ERROR"/>
<logger name="org.thymeleaf" level="ERROR"/>
<logger name="springfox.documentation" level="ERROR"/>
<logger name="org.hibernate.validator" level="ERROR"/>
<logger name="com.netflix.loadbalancer" level="ERROR"/>
<logger name="com.netflix.hystrix" level="ERROR"/>
<logger name="com.netflix.zuul" level="ERROR"/>
<logger name="de.codecentric" level="ERROR"/>
<!-- cache ERROR -->
<logger name="net.sf.ehcache" level="ERROR"/>
<logger name="org.springframework.cache" level="ERROR"/>
<!-- cloud -->
<logger name="org.apache.http" level="ERROR"/>
<logger name="com.netflix.discovery" level="ERROR"/>
<logger name="com.netflix.eureka" level="ERROR"/>
<!-- 业务日志 -->
<Logger name="org.springblade" level="ERROR"/>
<Logger name="org.springblade.core.version" level="ERROR"/>
<!-- 减少nacos日志 -->
<logger name="com.alibaba.nacos" level="ERROR"/>
</configuration>

127
hzims-service/operational/src/main/resources/log/logback-prod.xml

@ -0,0 +1,127 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="60 seconds">
<!-- 自定义参数监听 -->
<contextListener class="org.springblade.core.log.listener.LoggerStartupListener"/>
<!-- 彩色日志依赖的渲染类 -->
<conversionRule conversionWord="clr" converterClass="org.springframework.boot.logging.logback.ColorConverter"/>
<conversionRule conversionWord="wex"
converterClass="org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter"/>
<conversionRule conversionWord="wEx"
converterClass="org.springframework.boot.logging.logback.ExtendedWhitespaceThrowableProxyConverter"/>
<!-- 彩色日志格式 -->
<property name="CONSOLE_LOG_PATTERN"
value="${CONSOLE_LOG_PATTERN:-%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(${PID:- }){magenta} %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}}"/>
<!-- 控制台输出 -->
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>${CONSOLE_LOG_PATTERN}</pattern>
<charset>utf8</charset>
</encoder>
</appender>
<!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符 -->
<property name="log.pattern"
value="[%d{yyyy-MM-dd HH:mm:ss.SSS}] [%t] [%X{traceId}] %-5level %logger{50} - %msg%n"/>
<!-- 生成日志文件 -->
<appender name="INFO" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>log/info.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<!-- 日志文件输出的文件名 -->
<fileNamePattern>log/info/info-%d{yyyy-MM-dd_HH}.%i.log</fileNamePattern>
<!--设置保存10天 一天24个文件,一小时生成一个-->
<MaxHistory>240</MaxHistory>
<!--给定日志文件大小,超过指定的大小就新建一个日志文件-->
<maxFileSize>20MB</maxFileSize>
<totalSizeCap>10GB</totalSizeCap> <!-- 总日志大小 -->
<cleanHistoryOnStart>true</cleanHistoryOnStart>
</rollingPolicy>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<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="ERROR" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>log/error.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<!-- 日志文件输出的文件名 -->
<fileNamePattern>log/error/error-%d{yyyy-MM-dd_HH}.%i.log</fileNamePattern>
<!--设置保存15天 一天24个文件,一小时生成一个-->
<MaxHistory>360</MaxHistory>
<!--给定日志文件大小,超过指定的大小就新建一个日志文件-->
<maxFileSize>20MB</maxFileSize>
<totalSizeCap>10GB</totalSizeCap> <!-- 总日志大小 -->
<cleanHistoryOnStart>true</cleanHistoryOnStart>
</rollingPolicy>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>${log.pattern}</pattern>
</encoder>
<!-- 打印日志级别 -->
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>ERROR</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<!-- 日志输出级别 -->
<root level="ERROR">
<appender-ref ref="STDOUT"/>
<!--<appender-ref ref="INFO"/>-->
<appender-ref ref="ERROR"/>
</root>
<logger name="net.sf.ehcache" level="ERROR"/>
<logger name="druid.sql" level="ERROR"/>
<!-- MyBatis log configure -->
<logger name="com.apache.ibatis" level="ERROR"/>
<logger name="org.mybatis.spring" level="ERROR"/>
<logger name="java.sql.Connection" level="ERROR"/>
<logger name="java.sql.Statement" level="ERROR"/>
<logger name="java.sql.PreparedStatement" level="ERROR"/>
<!-- 减少部分debug日志 -->
<logger name="druid.sql" level="ERROR"/>
<logger name="org.apache.shiro" level="ERROR"/>
<logger name="org.mybatis.spring" level="ERROR"/>
<logger name="org.springframework" level="ERROR"/>
<logger name="org.springframework.context" level="ERROR"/>
<logger name="org.springframework.beans" level="ERROR"/>
<logger name="com.baomidou.mybatisplus" level="ERROR"/>
<logger name="org.apache.ibatis.io" level="ERROR"/>
<logger name="org.apache.velocity" level="ERROR"/>
<logger name="org.eclipse.jetty" level="ERROR"/>
<logger name="io.undertow" level="ERROR"/>
<logger name="org.xnio.nio" level="ERROR"/>
<logger name="org.thymeleaf" level="ERROR"/>
<logger name="springfox.documentation" level="ERROR"/>
<logger name="org.hibernate.validator" level="ERROR"/>
<logger name="com.netflix.loadbalancer" level="ERROR"/>
<logger name="com.netflix.hystrix" level="ERROR"/>
<logger name="com.netflix.zuul" level="ERROR"/>
<logger name="de.codecentric" level="ERROR"/>
<!-- cache INFO -->
<logger name="net.sf.ehcache" level="ERROR"/>
<logger name="org.springframework.cache" level="ERROR"/>
<!-- cloud -->
<logger name="org.apache.http" level="ERROR"/>
<logger name="com.netflix.discovery" level="ERROR"/>
<logger name="com.netflix.eureka" level="ERROR"/>
<!-- 业务日志 -->
<Logger name="org.springblade" level="ERROR"/>
<Logger name="org.springblade.core.version" level="ERROR"/>
<!-- 减少nacos日志 -->
<logger name="com.alibaba.nacos" level="ERROR"/>
</configuration>

127
hzims-service/operational/src/main/resources/log/logback-test.xml

@ -0,0 +1,127 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="60 seconds">
<!-- 自定义参数监听 -->
<contextListener class="org.springblade.core.log.listener.LoggerStartupListener"/>
<!-- 彩色日志依赖的渲染类 -->
<conversionRule conversionWord="clr" converterClass="org.springframework.boot.logging.logback.ColorConverter"/>
<conversionRule conversionWord="wex"
converterClass="org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter"/>
<conversionRule conversionWord="wEx"
converterClass="org.springframework.boot.logging.logback.ExtendedWhitespaceThrowableProxyConverter"/>
<!-- 彩色日志格式 -->
<property name="CONSOLE_LOG_PATTERN"
value="${CONSOLE_LOG_PATTERN:-%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(${PID:- }){magenta} %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}}"/>
<!-- 控制台输出 -->
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>${CONSOLE_LOG_PATTERN}</pattern>
<charset>utf8</charset>
</encoder>
</appender>
<!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符 -->
<property name="log.pattern"
value="[%d{yyyy-MM-dd HH:mm:ss.SSS}] [%t] [%X{traceId}] %-5level %logger{50} - %msg%n"/>
<!-- 生成日志文件
<appender name="INFO" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>log/info.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
&lt;!&ndash; 日志文件输出的文件名 &ndash;&gt;
<fileNamePattern>log/info/info-%d{yyyy-MM-dd_HH}.%i.log</fileNamePattern>
&lt;!&ndash;设置保存10天 一天24个文件,一小时生成一个&ndash;&gt;
<MaxHistory>240</MaxHistory>
&lt;!&ndash;给定日志文件大小,超过指定的大小就新建一个日志文件&ndash;&gt;
<maxFileSize>20MB</maxFileSize>
<totalSizeCap>10GB</totalSizeCap> &lt;!&ndash; 总日志大小 &ndash;&gt;
<cleanHistoryOnStart>true</cleanHistoryOnStart>
</rollingPolicy>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>${log.pattern}</pattern>
</encoder>
&lt;!&ndash; 打印日志级别 &ndash;&gt;
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>INFO</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
</appender>-->
<!-- 生成日志文件 -->
<appender name="ERROR" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>log/error.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<!-- 日志文件输出的文件名 -->
<fileNamePattern>log/error/error-%d{yyyy-MM-dd_HH}.%i.log</fileNamePattern>
<!--设置保存15天 一天24个文件,一小时生成一个-->
<MaxHistory>360</MaxHistory>
<!--给定日志文件大小,超过指定的大小就新建一个日志文件-->
<maxFileSize>20MB</maxFileSize>
<totalSizeCap>10GB</totalSizeCap> <!-- 总日志大小 -->
<cleanHistoryOnStart>true</cleanHistoryOnStart>
</rollingPolicy>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>${log.pattern}</pattern>
</encoder>
<!-- 打印日志级别 -->
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>ERROR</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<!-- 日志输出级别 -->
<root level="ERROR">
<appender-ref ref="STDOUT"/>
<!--<appender-ref ref="INFO"/>-->
<appender-ref ref="ERROR"/>
</root>
<logger name="net.sf.ehcache" level="ERROR"/>
<logger name="druid.sql" level="ERROR"/>
<!-- MyBatis log configure -->
<logger name="com.apache.ibatis" level="ERROR"/>
<logger name="org.mybatis.spring" level="ERROR"/>
<logger name="java.sql.Connection" level="ERROR"/>
<logger name="java.sql.Statement" level="ERROR"/>
<logger name="java.sql.PreparedStatement" level="ERROR"/>
<!-- 减少部分debug日志 -->
<logger name="druid.sql" level="ERROR"/>
<logger name="org.apache.shiro" level="ERROR"/>
<logger name="org.mybatis.spring" level="ERROR"/>
<logger name="org.springframework" level="ERROR"/>
<logger name="org.springframework.context" level="ERROR"/>
<logger name="org.springframework.beans" level="ERROR"/>
<logger name="com.baomidou.mybatisplus" level="ERROR"/>
<logger name="org.apache.ibatis.io" level="ERROR"/>
<logger name="org.apache.velocity" level="ERROR"/>
<logger name="org.eclipse.jetty" level="ERROR"/>
<logger name="io.undertow" level="ERROR"/>
<logger name="org.xnio.nio" level="ERROR"/>
<logger name="org.thymeleaf" level="ERROR"/>
<logger name="springfox.documentation" level="ERROR"/>
<logger name="org.hibernate.validator" level="ERROR"/>
<logger name="com.netflix.loadbalancer" level="ERROR"/>
<logger name="com.netflix.hystrix" level="ERROR"/>
<logger name="com.netflix.zuul" level="ERROR"/>
<logger name="de.codecentric" level="ERROR"/>
<!-- cache INFO -->
<logger name="net.sf.ehcache" level="ERROR"/>
<logger name="org.springframework.cache" level="ERROR"/>
<!-- cloud -->
<logger name="org.apache.http" level="ERROR"/>
<logger name="com.netflix.discovery" level="ERROR"/>
<logger name="com.netflix.eureka" level="ERROR"/>
<!-- 业务日志 -->
<Logger name="org.springblade" level="ERROR"/>
<Logger name="org.springblade.core.version" level="ERROR"/>
<!-- 减少nacos日志 -->
<logger name="com.alibaba.nacos" level="ERROR"/>
</configuration>
Loading…
Cancel
Save