Commit eee3540b by 宋祥

1.调整日志输出格式

parent f5bb819b
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN" monitorInterval="10"> <Configuration status="WARN">
<Properties>
<Property name="PID">mylog</Property> <properties>
<property name="LOG_HOME">./logs</property>
<Property name="LOG_EXCEPTION_CONVERSION_WORD">%xwEx</Property> <Property name="LOG_EXCEPTION_CONVERSION_WORD">%xwEx</Property>
<Property name="LOG_LEVEL_PATTERN">%5p</Property> <!--<Property name="LOG_PATTERN">%d{yyyy-MM-dd HH:mm:ss} %-5level [%thread][%file:%line] - %msg%n</Property>--> <Property name="LOG_LEVEL_PATTERN">%5p</Property>
<!--参考文档 https://logging.apache.org/log4j/2.x/manual/layouts.html#PatternLayout --> <Property name="LOG_PATTERN">%d{yyyy-MM-dd HH:mm:ss.SSS} %-5level[%thread] %logger{1.} - %msg%n</Property>
<Property name="LOG_PATTERN">%highlight{%d{yyyy-MM-dd HH:mm:ss} %-5level [%thread] %logger{1.} - %msg%n%}</Property> </properties>
<Property name="filename">iplat.$${date:yyyy-MM-dd}.log</Property>
</Properties> <Appenders>
<Appenders> <!--<Console name="Console" target="SYSTEM_OUT" follow="true">--> <!--<PatternLayout pattern="${LOG_PATTERN}"/>--> <!--</Console>--> <!-- 用来定义输出到控制台的配置 --> <!--*********************控制台日志***********************-->
<Console name="Console" target="SYSTEM_OUT"> <!-- 设置控制台只输出error及以上级别的信息(onMatch),其他的直接拒绝(onMismatch)--> <Console name="Console" target="SYSTEM_OUT" follow="true">
<ThresholdFilter level="INFO" onMatch="ACCEPT" onMismatch="DENY" /> <PatternLayout charset="GBK" pattern="${LOG_PATTERN}"/>
<PatternLayout pattern="${LOG_PATTERN}" />
</Console> </Console>
<RollingRandomAccessFile name="MyFile" fileName="apps/logs/iplat.log" filePattern="apps/logs/iplat.%d{yyyy-MM-dd}-%i.log.gz"> <TextArea name="platLogAppender">
<PatternLayout pattern="%m%n"/>
</TextArea>
<!--*********************文件日志***********************-->
<!--info级别日志-->
<RollingFile name="InfoAppender" fileName="${LOG_HOME}/info.log"
filePattern="${LOG_HOME}/%d{yyyy-MM-dd}/info-%i.log.gz">
<!-- <Filters>-->
<!-- &lt;!&ndash;过滤掉warn及更高级别日志&ndash;&gt;-->
<!-- <ThresholdFilter level="warn" onMatch="DENY" onMismatch="NEUTRAL"/>-->
<!-- </Filters>-->
<!--设置日志格式-->
<PatternLayout> <PatternLayout>
<Pattern>%d{yyyy-MM-dd HH:mm:ss} %-5level [%thread] %logger{1.} - %msg%n%throwable{short}</Pattern> <pattern>${LOG_PATTERN}</pattern>
</PatternLayout> </PatternLayout>
<Policies> <Policies>
<TimeBasedTriggeringPolicy interval="1" modulate="true" /> <!-- 设置日志文件切分参数 -->
<SizeBasedTriggeringPolicy size="1024 MB" /> <!--<OnStartupTriggeringPolicy/>-->
<!--设置日志基础文件大小,超过该大小就触发日志文件滚动更新-->
<SizeBasedTriggeringPolicy size="20MB"/>
<!--设置日志文件滚动更新的时间,依赖于文件命名filePattern的设置-->
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
</Policies> </Policies>
<DefaultRolloverStrategy max="50" /> <!--设置日志的文件个数上限,不设置默认为7个,超过大小后会被覆盖;依赖于filePattern中的%i-->
</RollingRandomAccessFile> <DefaultRolloverStrategy max="100"/>
<TextArea name="platLogAppender"> </RollingFile>
<PatternLayout pattern="%m%n" />
</TextArea> <!--warn级别日志-->
<RollingFile name="WarnAppender" fileName="${LOG_HOME}/warn.log"
filePattern="${LOG_HOME}/%d{yyyy-MM-dd}/warn-%i.log.gz">
<Filters>
<!--过滤掉error及更高级别日志-->
<ThresholdFilter level="error" onMatch="DENY" onMismatch="NEUTRAL"/>
</Filters>
<!--设置日志格式-->
<PatternLayout>
<pattern>${LOG_PATTERN}</pattern>
</PatternLayout>
<Policies>
<!-- 设置日志文件切分参数 -->
<!--<OnStartupTriggeringPolicy/>-->
<!--设置日志基础文件大小,超过该大小就触发日志文件滚动更新-->
<SizeBasedTriggeringPolicy size="20MB"/>
<!--设置日志文件滚动更新的时间,依赖于文件命名filePattern的设置-->
<TimeBasedTriggeringPolicy/>
</Policies>
<!--设置日志的文件个数上限,不设置默认为7个,超过大小后会被覆盖;依赖于filePattern中的%i-->
<DefaultRolloverStrategy max="100"/>
</RollingFile>
<!--error及更高级别日志-->
<RollingFile name="ErrorAppender" fileName="${LOG_HOME}/error.log"
filePattern="${LOG_HOME}/%d{yyyy-MM-dd}/error-%i.log.gz">
<!--设置日志格式-->
<PatternLayout>
<pattern>${LOG_PATTERN}</pattern>
</PatternLayout>
<Policies>
<!-- 设置日志文件切分参数 -->
<!--<OnStartupTriggeringPolicy/>-->
<!--设置日志基础文件大小,超过该大小就触发日志文件滚动更新-->
<SizeBasedTriggeringPolicy size="20MB"/>
<!--设置日志文件滚动更新的时间,依赖于文件命名filePattern的设置-->
<TimeBasedTriggeringPolicy/>
</Policies>
<!--设置日志的文件个数上限,不设置默认为7个,超过大小后会被覆盖;依赖于filePattern中的%i-->
<DefaultRolloverStrategy max="100"/>
</RollingFile>
<Async name="Async">
<AppenderRef ref="InfoAppender" level="info"/>
<AppenderRef ref="WarnAppender" level="warn"/>
<AppenderRef ref="ErrorAppender" level="error"/>
</Async>
</Appenders> </Appenders>
<Loggers> <!--用来增加sql的日志,无论下面root logger级别是什么都输出sql log-->
<logger name="com.baosight.iplat4j.core.data.ibatis.dao.SqlMapDaoLogProxy" level="ERROR" /> <Loggers>
<AsyncLogger name="com.baosight.iplat4j" level="INFO" additivity="false"> <!-- 根日志设置 -->
<AppenderRef ref="Console" /> <Root level="info">
<AppenderRef ref="MyFile" /> <AppenderRef ref="Console"/>
<AppenderRef ref="platLogAppender" /> <AppenderRef ref="Async"/>
</AsyncLogger>
<logger name="org.springframework" level="ERROR" />
<logger name="org.thymeleaf" level="ERROR" />
<Root level="INFO">
<AppenderRef ref="Console" />
<AppenderRef ref="MyFile" />
<AppenderRef ref="platLogAppender" />
</Root> </Root>
<!--用来增加sql的日志,无论下面root logger级别是什么都输出sql log-->
<logger name="com.baosight.iplat4j.core.data.ibatis.dao.SqlMapDaoLogProxy" level="info"/>
<!--spring日志-->
<Logger name="org.springframework" level="error"/>
<!-- mybatis日志 -->
<Logger name="com.mybatis" level="warn"/>
<Logger name="org.hibernate" level="warn"/>
<Logger name="com.zaxxer.hikari" level="warn"/>
<Logger name="org.quartz" level="warn"/>
</Loggers> </Loggers>
</Configuration> </Configuration>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment