小编ESC*_*mas的帖子

我无法在多个条件下配置log4j2属性文件

我是Elasticsearch用户,必须使用log4j2.properties文件。不幸的是,我无法按照自己的意愿删除日志。

我希望每天轮换一些日志文件(对应于某种模式)。我还希望如果旋转的日志文件符合我的2个条件之一,则将其删除:

  • 如果他们超过3个月大
  • 如果这些文件的总大小超过200兆。

我尝试使用该log4j2文档中介绍的PathCondition“ ifany”:https ://logging.apache.org/log4j/2.x/manual/appenders.html

这是我的log4j2.properties文件:

status = error

# log action execution errors for easier debugging
logger.action.name = org.elasticsearch.action
logger.action.level = debug

appender.console.type = Console
appender.console.name = console
appender.console.layout.type = PatternLayout
appender.console.layout.pattern = [%d{ISO8601}][%-5p][%-25c{1.}] %marker%m%n

appender.rolling.type = RollingFile
appender.rolling.name = rolling
appender.rolling.fileName = ${sys:es.logs}.log
appender.rolling.layout.type = PatternLayout
appender.rolling.layout.pattern = [%d{ISO8601}][%-5p][%-25c{1.}] %marker%.-10000m%n
appender.rolling.filePattern = ${sys:es.logs}-%d{yyyy-MM-dd}.log
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.strategy.type = DefaultRolloverStrategy
appender.rolling.strategy.action.type = Delete
appender.rolling.strategy.action.basepath = /var/log/elasticsearch
appender.rolling.strategy.action.condition.type …
Run Code Online (Sandbox Code Playgroud)

properties conditional-statements log4j2

3
推荐指数
1
解决办法
1099
查看次数