es log configuration, save only the last three days of log

Elasticsearch logging using Log4j 2. You can use the configuration file log4j2.properties Log4j2.
Elasticsearch open three properties

${sys:es.logs.base_path},
${sys:es.logs.cluster_name}
${sys:es.logs.node_name}

May be referenced in the configuration file, the log file to determine the location.
This attribute ${sys:es.logs.base_path}resolves to the log directory,
${sys:es.logs.cluster_name}the cluster name is resolved (as a prefix to the name of the log file in the default configuration),
${sys:es.logs.node_name}and the node name is resolved (if explicitly set the node name).

For example, if you log directory (path.logs) is / var / log / elasticsearch and your cluster is named production and $ {sys: es.logs.base_path} will resolve / var / log / elasticsearch and \ ({sys : es.logs.base_path} \) {SYS: SYS File.separator} $ {:} .log es.logs.cluster_name resolves /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

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

Guess you like

Origin www.cnblogs.com/sanduzxcvbnm/p/12176448.html