zoukankan      html  css  js  c++  java
  • 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
    
    ################################################
    
  • 相关阅读:
    如何根据二叉树 前序遍历 中序遍历 后序遍历 中的两种遍历来反推另一种遍历
    dijkstral改编
    纪念做出来的第一道计算几何题
    链式前向星
    一道简单树形dp
    算法进阶指南—特殊排序
    算法进阶指南二分章节的两道题
    秦皇岛winter camp 总结
    C
    一道cf水题
  • 原文地址:https://www.cnblogs.com/sanduzxcvbnm/p/12176448.html
Copyright © 2011-2022 走看看