我想按以下方式更改ElasticSearch的log4j2配置。來自ElasticSearch的日誌應該保存在目錄中:/path/to/log/{year}/{month}/{day}/cluster_name.log
但是TimeBasedTriggeringPolicy只能在一天結束後進行翻轉。我一直試圖使用TimeBasedRollingPolicy,但它不能通過* .properties文件進行配置。我將整個log4j2.properties重新編譯爲log4j2.xml文件,但ElasticSearch需要log4j2.properties。最後,我決定辭去信件日記錄到適當的目錄。我返回到TimeBasedTriggeringPolicy,我用這個文件模式/path/to/log/%d{yyyy/MM/dd}/cluster_name.log
,但仍然無法正常工作。配置文件的log4j2.properties每日滾動不起作用
較大的部分:
appender.rolling.type = RollingFile
appender.rolling.name = rolling
appender.rolling.fileName = /path/to/log/cluster_name.log
appender.rolling.layout.type = PatternLayout
appender.rolling.layout.pattern = [%d{ISO8601}][%-5p][%-25c{1.}] %marker%.-10000m%n
appender.rolling.filePattern = /path/to/log/%d{yyyy/MM/dd}/cluster_name.log
appender.rolling.policies.type = Policies
appender.rolling.policies.time.type = TimeBasedTriggeringPolicy
appender.rolling.policies.time.interval = 1
appender.rolling.policies.time.modulate = true
仍然不會創建任何目錄。 –