Skip to content

Commit

Permalink
Merge pull request #51 from PerimeterX/master
Browse files Browse the repository at this point in the history
Added saner production rolling log file options
  • Loading branch information
ernestas-poskus authored Oct 11, 2016
2 parents b8f20df + 26a07b0 commit 625ad03
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 0 deletions.
4 changes: 4 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ log_dir: /var/log/zookeeper
zookeeper_dir: /opt/zookeeper-{{zookeeper_version}}
zookeeper_tarball_dir: /opt/src

# Rolling file appender setttings
zookeeper_rolling_log_file_max_size: 10MB
zookeeper_max_rolling_log_file_count: 10

# List of dict (i.e. {zookeeper_hosts:[{host:,id:},{host:,id:},...]})
zookeeper_hosts:
- host: "{{inventory_hostname}}" # the machine running
Expand Down
6 changes: 6 additions & 0 deletions tasks/common-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
- Restart zookeeper
when: zookeeper_env is defined and zookeeper_env|length > 0

- name: Update the log4j config with saner production values
template: src=log4j.properties.j2 dest={{ zookeeper_dir }}/conf/log4j.properties
tags: deploy
notify:
- Restart zookeeper

- name: Start zookeeper service
service: name=zookeeper state=started enabled=yes
tags: deploy
58 changes: 58 additions & 0 deletions templates/log4j.properties.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Define some default values that can be overridden by system properties
zookeeper.root.logger=INFO, CONSOLE, ROLLINGFILE
zookeeper.console.threshold=INFO
zookeeper.log.dir=.
zookeeper.log.file=zookeeper.log
zookeeper.log.threshold=DEBUG
zookeeper.tracelog.dir=.
zookeeper.tracelog.file=zookeeper_trace.log

#
# ZooKeeper Logging Configuration
#

# Format is "<default threshold> (, <appender>)+

# DEFAULT: console appender only
log4j.rootLogger=${zookeeper.root.logger}

# Example with rolling log file
#log4j.rootLogger=DEBUG, CONSOLE, ROLLINGFILE

# Example with rolling log file and tracing
#log4j.rootLogger=TRACE, CONSOLE, ROLLINGFILE, TRACEFILE

#
# Log INFO level and above messages to the console
#
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
log4j.appender.CONSOLE.Threshold=${zookeeper.console.threshold}
log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
log4j.appender.CONSOLE.layout.ConversionPattern=%d{ISO8601} [myid:%X{myid}] - %-5p [%t:%C{1}@%L] - %m%n

#
# Add ROLLINGFILE to rootLogger to get log file output
# Log DEBUG level and above messages to a log file
log4j.appender.ROLLINGFILE=org.apache.log4j.RollingFileAppender
log4j.appender.ROLLINGFILE.Threshold=${zookeeper.log.threshold}
log4j.appender.ROLLINGFILE.File=${zookeeper.log.dir}/${zookeeper.log.file}

# Max log file size of 10MB
log4j.appender.ROLLINGFILE.MaxFileSize={{ zookeeper_rolling_log_file_max_size }}
# uncomment the next line to limit number of backup files
log4j.appender.ROLLINGFILE.MaxBackupIndex={{ zookeeper_max_rolling_log_file_count }}

log4j.appender.ROLLINGFILE.layout=org.apache.log4j.PatternLayout
log4j.appender.ROLLINGFILE.layout.ConversionPattern=%d{ISO8601} [myid:%X{myid}] - %-5p [%t:%C{1}@%L] - %m%n


#
# Add TRACEFILE to rootLogger to get log file output
# Log DEBUG level and above messages to a log file
log4j.appender.TRACEFILE=org.apache.log4j.FileAppender
log4j.appender.TRACEFILE.Threshold=TRACE
log4j.appender.TRACEFILE.File=${zookeeper.tracelog.dir}/${zookeeper.tracelog.file}

log4j.appender.TRACEFILE.layout=org.apache.log4j.PatternLayout
### Notice we are including log4j's NDC here (%x)
log4j.appender.TRACEFILE.layout.ConversionPattern=%d{ISO8601} [myid:%X{myid}] - %-5p [%t:%C{1}@%L][%x] - %m%n

0 comments on commit 625ad03

Please sign in to comment.