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 ################################################

最新文章

  1. tornado--SESSION框架,一致性hash,分布式存储
  2. java-汉字转化拼音(纯java)
  3. memcached缓存知识简单梳理
  4. Bus Pass
  5. 基类和派生类--this
  6. cocos2d中如何使用图片纹理图集的加载来实现一个动画的功能
  7. windows10 预览版 中英文官方下载地址+激活密钥+网盘分享
  8. windows下使用python googleprotobuf
  9. 偶尔发生File has been moved - cannot be read again,其实是个误解
  10. curl 获取外网IP
  11. ubuntu12.04:Tomcat 7服务器:手动安装
  12. jmeter beanshell遍历接口返回的json数组
  13. Linux 的终端及设置
  14. python数据库操作
  15. vscode 常用插件
  16. 【Promise】Promise实现请求超时处理(加强版)
  17. Java并发编程(十二)Callable、Future和FutureTask
  18. 百度地图API如何给自定义覆盖物添加事件
  19. D12——C语言基础学PYTHON
  20. sprintboot 发布

热门文章

  1. if else 还在用吗?
  2. Java方法的重写
  3. Linux shell脚本进阶使用
  4. Solution -「线段树」题目集合
  5. 串口应用:遵循uart协议发送N位数据(状态优化为3个,适用任意长度的输入数据,取寄存器中的一段(用变量作为边界))
  6. Linux一些错误总结
  7. 迷宫类dp整合
  8. HTML js 复习
  9. PHP生成器yield使用示例
  10. redis安装与连接