How to add serveral deletion conditions on log4j2.properties?

馋奶兔 提交于 2019-12-03 08:29:41
Vikas Sachdeva

Try below configuration for DeleteAction -

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.fileSize.type = IfAccumulatedFileSize
appender.rolling.strategy.action.condition.nested_condition.fileSize.exceeds = 2GB
appender.rolling.strategy.action.condition.nested_condition.lastMod.type = IfLastModified
appender.rolling.strategy.action.condition.nested_condition.lastMod.age = 7D

You can check some more examples in log4j2 documentation

NOTE: The key line in this example is this one:

appender.rolling.strategy.action.condition.nested_condition.type = IfAny

This configures log4j2 to delete when any of the conditions is met (> 2GB or last modified 7D+).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!