# Copyright 2012 The Apache Software Foundation
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements.  See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership.  The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License.  You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Define some default values that can be overridden by system properties
# Format is "<default threshold> (, <appender>)+
# zookeeper.root.logger=INFO, CONSOLE
zookeeper.root.logger=<%= scope.lookupvar("zookeeper::log4j_prop") %>

zookeeper.console.threshold=<%= scope.lookupvar("zookeeper::console_threshold") %>

zookeeper.log.dir=<%= scope.lookupvar("zookeeper::log_dir") %>
zookeeper.log.file=zookeeper.log
zookeeper.log.threshold=<%= scope.lookupvar("zookeeper::rollingfile_threshold") %>
zookeeper.log.maxfilesize=<%= scope.lookupvar("zookeeper::maxfilesize") %>
zookeeper.log.maxbackupindex=<%= scope.lookupvar("zookeeper::maxbackupindex") %>

zookeeper.tracelog.dir=${zookeeper.log.dir}
zookeeper.tracelog.file=zookeeper_trace.log

log4j.rootLogger=${zookeeper.root.logger}

<% if scope.lookupvar("zookeeper::audit_enable") -%>
#
# zk audit logging
#
audit.logger=INFO, RFAAUDIT
zookeeper.auditlog.file=zookeeper_audit.log
zookeeper.auditlog.threshold=<%= scope.lookupvar("zookeeper::audit_threshold") %>
log4j.logger.org.apache.zookeeper.audit.Log4jAuditLogger=${audit.logger}
log4j.additivity.org.apache.zookeeper.audit.Log4jAuditLogger=false
log4j.appender.RFAAUDIT=org.apache.log4j.RollingFileAppender
log4j.appender.RFAAUDIT.File=${zookeeper.log.dir}/${zookeeper.auditlog.file}
log4j.appender.RFAAUDIT.layout=org.apache.log4j.PatternLayout
log4j.appender.RFAAUDIT.layout.ConversionPattern=%d{ISO8601} %p %c{2}: %m%n
log4j.appender.RFAAUDIT.Threshold=${zookeeper.auditlog.threshold}

log4j.appender.RFAAUDIT.MaxFileSize=<%= scope.lookupvar("zookeeper::audit_maxfilesize") %>
log4j.appender.RFAAUDIT.MaxBackupIndex=<%= scope.lookupvar("zookeeper::audit_maxbackupindex") %>
<% end -%>

#
# console
# Add "console" to rootlogger above if you want to use this
#
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
#
log4j.appender.ROLLINGFILE=org.apache.log4j.RollingFileAppender
log4j.appender.ROLLINGFILE.Threshold=${zookeeper.log.threshold}
log4j.appender.ROLLINGFILE.File=${zookeeper.log.dir}/${zookeeper.log.file}
log4j.appender.ROLLINGFILE.MaxFileSize=${zookeeper.log.maxfilesize}
log4j.appender.ROLLINGFILE.MaxBackupIndex=${zookeeper.log.maxbackupindex}
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 ${TRACEFILE.Threshold} level and above messages to a log file
#
log4j.appender.TRACEFILE=org.apache.log4j.FileAppender
log4j.appender.TRACEFILE.Threshold=<%= scope.lookupvar("zookeeper::tracefile_threshold") %>
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
<% @extra_appenders.sort.map do |name, data| -%>

<% data.sort.map do |key, value| -%>
log4j.appender.<%= name.upcase %><% if key != 'class' %>.<%= key %><% end %>=<%= value %>
<% end -%>
<% end -%>
