Skip to content

Instantly share code, notes, and snippets.

@jaytaylor
Created January 26, 2018 23:36
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jaytaylor/70f9c0bb0362525d1cdf4d58506eed9b to your computer and use it in GitHub Desktop.
Save jaytaylor/70f9c0bb0362525d1cdf4d58506eed9b to your computer and use it in GitHub Desktop.
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