triggering
项目使用了logback,日志打印需要按照每天和大小生成日志,于是使用了TimebasedRollingPolicy SizeBasedTriggeringPolicy
[html] view plain copy
- <APPender name="FILE" class="ch.qos.logback.core.rolling.RollingFileappender">
- <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
- <FileNamePattern>${LOG_HOME}/consumer.%d{yyyy-MM-dd_HH}.log</FileNamePattern>
- <!-- 日志文件保留天数 -->
- <MaxHistory>30</MaxHistory>
- </rollingPolicy>
- <encoder class="ch.qos.logback.classic.encoder.PatternlayoutEncoder">
- <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern>
- </encoder>
- <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
- <!-- 文件大小触发重写新文件 -->
- <MaxFileSize>10MB</MaxFileSize>
- </triggeringPolicy>
- </appender>
但是在实际使用中并未有按照预期根据日期和大小生成日志,查了了相关文章说是TimeBasedRollingPolicy和SizeBasedTriggeringPolicy冲突,在根据网上的资料去看了logback的官网地址https://logback.qos.ch/manual/appenders.html#SizeAndTimeBasedFNATP,在游览了之后发现了最重要的部分
- Size and time based rolling policy
- Sometimes you may wish to archive files essentially by date but at the same time limit the size of each log file, in particular if post-processing tools impose size limits on the log files. In order to address this requirement, logback ships with SizeAndTimeBasedRollingPolicy.
- Note that TimeBasedRollingPolicy already allows limiting the combined size of archived log files. If you only wish to limit the combined size of log archives, then TimeBasedRollingPolicy described above and setting the totalSizeCap property should be amply sufficent.
- Here is a sample configuration file demonstrating time and size based log file archiving.
- example: Sample configuration for SizeAndTimeBasedFNATP (logback-examples/src/main/resources/chapters/appenders/conf/logback-sizeAndTime.xml)
- View as .groovy
- <configuration>
- <appender name="ROLLING" class="ch.qos.logback.core.rolling.RollingFileAppender">
- <file>mylog.txt</file>
- <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
- <!-- rollover daily -->
- <fileNamePattern>mylog-%d{yyyy-MM-dd}.%i.txt</fileNamePattern>
- <!-- each file should be at most 100MB, keep 60 days worth of history, but at most 20GB -->
- <maxFileSize>100MB</maxFileSize>
- <maxHistory>60</maxHistory>
- <totalSizeCap>20GB</totalSizeCap>
- </rollingPolicy>
- <encoder>
- <pattern>%msg%n</pattern>
- </encoder>
- </appender>
- <root level="DEBUG">
- <appender-ref ref="ROLLING" />
- </root>
- </configuration>
[html] view plain copy
- <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
- <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
- <!-- rollover daily -->
- <fileNamePattern>${LOG_HOME}/consumer.%d{yyyy-MM-dd}.%i.log</fileNamePattern>
- <!-- each file should be at most 100MB, keep 60 days worth of history, but at most 20GB -->
- <maxFileSize>50MB</maxFileSize>
- <maxHistory>30</maxHistory>
- </rollingPolicy>
- <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
- <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern>
- </encoder>
- </appender>
然后就ok了,日志文件中的%d、%i是不可缺少的。
以上是网上抄取的,自己项目的配置改成如下代码:
相关阅读
word2016自带公式编辑器转换成mathtype类型公式,以及设
投稿时需要mathtype类型公式,而我是用word自带的公式编辑器,所以凉凉了。一、公式转换打开要转换的文件,选中要转换的公式,选择mathty
/* 小方平电脑 高度可以满屏 ; 16:9 的电脑 宽度可以满屏 */<!DOCTYPE html><html><head lang="en"><meta charset="UTF
图片太大怎么办?如何将图片压缩到100K以下,现在很多的网站对图片的限制还是比较大的,有些网站图片超过100K就不可以上传,如果需要将图
以前逛淘宝都是看图片来决定买不买,如今大家更多的是看宝贝的视频来抉择,因为视频不仅是动态的,而且还附带了声音介绍,所以承载的内容
本文就总结一下:通过 PS软件 ,对图片进行有效 压缩 ,进而达到网站的优化,缩短完成加载的时间 ! 我们以上面的JPG图片为例(PNG图片同样