Instantly share code, notes, and snippets.

Embed
What would you like to do?
Elasticsearch log4j2.properties file for hybrid console + disk-based logging, with rotation and expiration.
status = error
dest = err
name = PopertiesConfig
property.logDir = /var/log/elasticsearch
appender.console.type = Console
appender.console.name = STDOUT
appender.console.layout.type = PatternLayout
appender.console.layout.pattern = [%d{ISO8601}][%-5p][%-25c{1.}] %marker%m%n
appender.rolling.type = RollingFile
appender.rolling.name = RollingFile
appender.rolling.fileName = ${logDir}/elasticsearch.log
appender.rolling.filePattern = ${logDir}/elasticsearch-%d{MM-dd-yy-HH-mm-ss}-%i.log.gz
appender.rolling.layout.type = PatternLayout
appender.rolling.layout.pattern = [%d{ISO8601}][%-5p][%-25c{1.}] %marker%m%n
appender.rolling.policies.type = Policies
appender.rolling.policies.time.type = TimeBasedTriggeringPolicy
appender.rolling.policies.time.interval = 24
appender.rolling.policies.time.modulate = true
appender.rolling.policies.size.type = SizeBasedTriggeringPolicy
appender.rolling.policies.size.size = 25MB
appender.rolling.strategy.type = DefaultRolloverStrategy
appender.rolling.strategy.action.type = Delete
appender.rolling.strategy.action.basePath = ${logDir}
appender.rolling.strategy.action.maxDepth = 1
# Delete files older than 30 days.
appender.rolling.strategy.action.ageCondition.type = IfLastModified
appender.rolling.strategy.action.ageCondition.age = 30D
# With filenames matching the glob expression "*.log.gz".
appender.rolling.strategy.action.pathCondition.type = IfFileName
appender.rolling.strategy.action.pathCondition.glob = *.log.gz
appender.console.filter.threshold.type = ThresholdFilter
appender.console.filter.threshold.level = info
logger.console.name = STDOUT
logger.console.level = info
logger.console.appenderRef.console.ref = STDOUT
logger.rolling.name = RollingFile
logger.rolling.level = info
logger.rolling.appenderRef.rolling.ref = RollingFile
rootLogger.level = info
rootLogger.appenderRef.console.ref = STDOUT
rootLogger.appenderRef.rolling.ref = RollingFile