限制Elasticsearch日志中的文件数

时间:2018-10-09 20:51:03

标签: elasticsearch log4j2

我正在配置elasticsearch日志转换配置log4j2.properties文件。

这是我的属性文件:

appender.rolling.type = RollingFile
appender.rolling.name = rolling
appender.rolling.fileName = ${sys:es.logs.base_path}${sys:file.separator}${sys:es.logs.cluster_name}.log
appender.rolling.layout.type = PatternLayout
appender.rolling.layout.pattern = [%d{ISO8601}][%-5p][%-25c{1.}] [%node_name]%marker %.-10000m%n
appender.rolling.filePattern = ${sys:es.logs.base_path}${sys:file.separator}${sys:es.logs.cluster_name}-%d{yyyy-MM-dd}-%i.log.zip
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 = 128MB
appender.rolling.strategy.type = DefaultRolloverStrategy
appender.rolling.strategy.action.type = Delete
appender.rolling.strategy.action.basepath = ${sys:es.logs.base_path}
appender.rolling.strategy.action.condition.type = IfFileName
appender.rolling.strategy.action.condition.glob = ${sys:es.logs.cluster_name}-*
appender.rolling.strategy.action.condition.nested_condition.type = IfAny
appender.rolling.strategy.action.condition.nested_condition.lastMod.type = IfLastModified
appender.rolling.strategy.action.condition.nested_condition.lastMod.age = 7D
appender.rolling.strategy.action.condition.nested_condition.fileCount.type = IfAccumulatedFileCount
appender.rolling.strategy.action.condition.nested_condition.fileCount.exceeds = 10

我希望删除7天以上的文件,并且整天的文件总数不应超过10。

fileCount.type是我在属性文件中尝试过的东西,但是没有用。

我关注的链接很少,但是他们考虑使用lastMod累积文件大小的情况。 Here是我关注的链接

谢谢!

0 个答案:

没有答案