ESは、ログの最後の3日間保存した構成を記録します

Log4jの2を使用してログインするElasticsearch。あなたは、設定ファイルlog4j2.properties Log4j2を使用することができます。
オープンの3つのプロパティを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}かつ(明示的にノード名を設定している場合)、ノード名が解決されます。

たとえば、あなたは/ var /ログ/ elasticsearchディレクトリ(path.logs)にログインして、クラスタが命名生産と$ {SYS:es.logs.base_pathを}である場合は/ var / log / elasticsearchとを解決します(\ {SYS :es.logs.base_path} \) {SYS:SYS File.separator} $ {。}の.log es.logs.cluster_name解決さ/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

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

おすすめ

転載: www.cnblogs.com/sanduzxcvbnm/p/12176448.html