ES Log4J配置信息

# 配置RollingFileappender
appender.rolling.type = RollingFile 
appender.rolling.name = rolling
# 日志名称 /var/log/elasticsearch/production.log
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.}] %marker%.-10000m%n
# 滚动日志到/var/log/elasticsearch/production-yyyy-MM-dd-i.log; 日志将被压缩在每个滚动,i并将增加
appender.rolling.filePattern = ${sys:es.logs.base_path}${sys:file.separator}${sys:es.logs.cluster_name}-%d{yyyy-MM-dd}-%i.log.gz 
appender.rolling.policies.type = Policies
# 使用基于时间的滚动策略
appender.rolling.policies.time.type = TimeBasedTriggeringPolicy 
# 每天滚动日志
appender.rolling.policies.time.interval = 1 
# 在日边界上对齐滚动(而不是每24小时滚动一次)
appender.rolling.policies.time.modulate = true 
# 使用基于文件大小的滚动策略,比如文件到了100M
appender.rolling.policies.size.type = SizeBasedTriggeringPolicy 
# 文件大小在256 MB之后滚动日志
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 
# 压缩日志上的大小条件是2 GB
appender.rolling.strategy.action.condition.nested_condition.exceeds = 2GB 

  

如果要在指定的时间段内保留日志文件,则可以使用带有删除操作的滚动策略。

 

# 配置 DefaultRolloverStrategy
appender.rolling.strategy.type = DefaultRolloverStrategy 
# 配置Delete处理滚动的动作
appender.rolling.strategy.action.type = Delete 
# Elasticsearch日志的基本路径
appender.rolling.strategy.action.basepath = ${sys:es.logs.base_path} 
# 处理滚动时应用的条件
appender.rolling.strategy.action.condition.type = IfFileName 
# 从与glob匹配的基本路径中删除文件 ${sys:es.logs.cluster_name}-*; 这是日志文件滚动到的glob; 只需要删除滚动的Elasticsearch日志,而不是删除弃用和慢日志
appender.rolling.strategy.action.condition.glob = ${sys:es.logs.cluster_name}-* 
# 嵌套的条件适用于与glob匹配的文件
appender.rolling.strategy.action.condition.nested_condition.type = IfLastModified 
# 保留七天的日志
appender.rolling.strategy.action.condition.nested_condition.age = 7D 

  

原文链接:https://blog.csdn.net/qq_21383435/article/details/79295329

转载于:https://www.cnblogs.com/woniu4/p/9920874.html

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值