elastic设置日志保存时间_es日志配置,只保存最近3天的日志

Elasticsearch使用Log4j 2进行日志记录。可以使用log4j2.properties文件配置Log4j2。

Elasticsearch公开三个属性

${sys:es.logs.base_path},

${sys:es.logs.cluster_name}

${sys:es.logs.node_name}

可以在配置文件中被引用,以确定日志文件的位置。

该属性${sys:es.logs.base_path}将解析为日志目录,

${sys:es.logs.cluster_name}将解析为群集名称(在默认配置中用作日志文件名的前缀),

${sys:es.logs.node_name}并将解析为节点名称(如果显式设置了节点名称)。

例如,如果你的日志目录(path.logs)是/var/log/elasticsearch和您的群集名为production然后${sys:es.logs.base_path}将解析/var/log/elasticsearch和 \({sys:es.logs.base_path}\){sys:file.separator}${sys:es.logs.cluster_name}.log 将解析/var/log/elasticsearch/production.log。

######## Server JSON ############################

appender.rolling.type = RollingFile

appender.rolling.name = rolling

appender.rolling.fileName = ${sys:es.logs.base_path}${sys:file.separator}${sys:es.logs.cluster_name}_server.json

appender.rolling.layout.type = ESJsonLayout

appender.rolling.layout.type_name = server

appender.rolling.filePattern = ${sys:es.logs.base_path}${sys:file.separator}${sys:es.logs.cluster_name}-%d{yyyy-MM-dd}-%i.json.gz

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 = 256MB

appender.rolling.strategy.type = DefaultRolloverStrategy

appender.rolling.strategy.fileIndex = nomax

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 = IfAccumulatedFileSize

appender.rolling.strategy.action.condition.nested_condition.exceeds = 2GB

# 若是只保留最近3天的日志,把上面最后两行换成下面这两行

#appender.rolling.strategy.action.condition.nested_condition.type = IfLastModified

#appender.rolling.strategy.action.condition.nested_condition.age = 3D

################################################

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值