目前使用以下属性文件。能够存档基于规模的触发策略。但是,如果日期从一个日期更改为另一个日期,则上一日期的最后一个日志文件无法归档。
property.basePath = H:/Application/Application_Name
appender.console.layout.pattern = %d{yyyy-MM-dd'T'hh:mm:ss.SSSXXX} %-5p [%tid] [%t] [%r] %x %c %M - %m%n
appender.rolling.type = RollingFile
appender.rolling.name = fileLogger
appender.rolling.fileName=${basePath}/hello_log-${date:MM-dd-yyyy}.log
appender.rolling.filePattern=${basePath}/$${date:yyyyMMdd}/helloSTC_log-%d{MM-dd-yyyy}-%i.log.zip
appender.rolling.layout.type = PatternLayout
appender.rolling.layout.pattern = %d{yyyy-MM-dd'T'hh:mm:ss.SSSXXX} %-5p [%tid] [%t] [%r] %x %c %M - %m%n
appender.rolling.policies.type = Policies
appender.rolling.policies.time.type = TimeBasedTriggeringPolicy
appender.rolling.policies.time.interval = 1
appender.rolling.policies.time.modulate = true
appender.rolling.policies.size.type=SizeBasedTriggeringPolicy
appender.rolling.policies.size.size=100MB
appender.rolling.strategy.type = DefaultRolloverStrategy
appender.rolling.strategy.max = 100
appender.rolling.strategy.delete.type = Delete
appender.rolling.strategy.delete.basePath = ${basePath}
appender.rolling.strategy.delete.maxDepth = 2
appender.rolling.strategy.delete.ifLastModified.type = IfLastModified
appender.rolling.strategy.delete.ifLastModified.age = 30d
logger.application.name = com.example
logger.application.level = info
logger.application.additivity = false
logger.application.appenderRef.rolling.ref = fileLogger
rootLogger.level = error
rootLogger.additivity = false
rootLogger.appenderRef.rolling.ref = fileLogger
答案 0 :(得分:0)
您是否尝试过仅使用SimpleDateFormat模式?
appender.rolling.fileName=${basePath}/hello_log-%d{MM-dd-yyyy}.log
appender.rolling.filePattern=${basePath}/%d{yyyyMMdd}/helloSTC_log-%d{MM-dd-yyyy}-%i.log.zip