This is an automated email from the ASF dual-hosted git repository.

kturner pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/fluo-muchos.git


The following commit(s) were added to refs/heads/master by this push:
     new d9b2473  Fixes #344 Support log4j2 w/ Accumulo 2.1.0 (#351)
d9b2473 is described below

commit d9b2473185b3b7b01ef71ad16c0797caddd18ff8
Author: Keith Turner <[email protected]>
AuthorDate: Thu May 21 09:47:10 2020 -0400

    Fixes #344 Support log4j2 w/ Accumulo 2.1.0 (#351)
---
 ansible/roles/accumulo/tasks/main.yml              | 28 ++++---
 ansible/roles/accumulo/templates/accumulo-env.sh   | 15 +++-
 .../accumulo/templates/log4j2-service.properties   | 91 ++++++++++++++++++++++
 ansible/roles/accumulo/templates/log4j2.properties | 41 ++++++++++
 4 files changed, 165 insertions(+), 10 deletions(-)

diff --git a/ansible/roles/accumulo/tasks/main.yml 
b/ansible/roles/accumulo/tasks/main.yml
index bb6dd78..b1341f4 100644
--- a/ansible/roles/accumulo/tasks/main.yml
+++ b/ansible/roles/accumulo/tasks/main.yml
@@ -25,29 +25,39 @@
     - monitor_logger.xml
     - log4j.properties
   when: accumulo_major_version == '1'
-- name: "configure accumulo 2.0 configuration"
+- name: "configure accumulo 1.0 configuration"
   template: src={{ item }} dest={{ accumulo_home }}/conf/{{ item }}
   with_items:
     - accumulo-env.sh
-    - accumulo.properties
-    - accumulo-client.properties
+    - accumulo-site.xml
+    - client.conf
     - gc
     - tracers
     - masters
     - monitor
-    - log4j-service.properties
-  when: accumulo_major_version == '2'
-- name: "configure accumulo 1.0 configuration"
+  when: accumulo_major_version == '1'
+- name: "configure accumulo 2.X configuration"
   template: src={{ item }} dest={{ accumulo_home }}/conf/{{ item }}
   with_items:
     - accumulo-env.sh
-    - accumulo-site.xml
-    - client.conf
+    - accumulo.properties
+    - accumulo-client.properties
     - gc
     - tracers
     - masters
     - monitor
-  when: accumulo_major_version == '1'
+  when: accumulo_major_version == '2'
+- name: "configure accumulo 2.0.0 logging"
+  command: cp {{ accumulo_home }}/conf/templates/{{ item }} {{ accumulo_home 
}}/conf/ creates={{ accumulo_home }}/conf/{{ item }}
+  with_items:
+    - log4j-service.properties
+  when: accumulo_version is version('2.0.0','>=') and accumulo_version is 
version('2.1.0','<')
+- name: "configure accumulo >= 2.1.0 logging"
+  command: cp {{ accumulo_home }}/conf/templates/{{ item }} {{ accumulo_home 
}}/conf/ creates={{ accumulo_home }}/conf/{{ item }}
+  with_items:
+    - log4j2.properties
+    - log4j2-service.properties
+  when: accumulo_version is version('2.1.0','>=')
 - name: "configure accumulo to send metrics (if metrics server exists)"
   template: src={{ item }} dest={{ accumulo_home }}/conf/{{ item }}
   with_items:
diff --git a/ansible/roles/accumulo/templates/accumulo-env.sh 
b/ansible/roles/accumulo/templates/accumulo-env.sh
index 365050c..5c1a003 100755
--- a/ansible/roles/accumulo/templates/accumulo-env.sh
+++ b/ansible/roles/accumulo/templates/accumulo-env.sh
@@ -86,17 +86,30 @@ case "$cmd" in
   *)       JAVA_OPTS=("${JAVA_OPTS[@]}" '-Xmx256m' '-Xms64m') ;;
 esac
 
+
+
 JAVA_OPTS=("${JAVA_OPTS[@]}"
   "-Daccumulo.log.dir=${ACCUMULO_LOG_DIR}"
-  "-Daccumulo.application=${cmd}${ACCUMULO_SERVICE_INSTANCE}_$(hostname)")
+  "-Daccumulo.application=${cmd}${ACCUMULO_SERVICE_INSTANCE}_$(hostname)"
+{% if accumulo_version is version('2.1.0','>=') %}
+   "-Daccumulo.metrics.service.instance=${ACCUMULO_SERVICE_INSTANCE}"
+   
"-Dlog4j2.contextSelector=org.apache.logging.log4j.core.async.AsyncLoggerContextSelector"
+{% endif %}
+)
 
 case "$cmd" in
+{% if accumulo_version is version('2.1.0','>=') %}
+  monitor|gc|master|tserver|tracer)
+    JAVA_OPTS=("${JAVA_OPTS[@]}" 
"-Dlog4j.configurationFile=log4j2-service.properties")
+    ;;
+{% else %}
   monitor)
     JAVA_OPTS=("${JAVA_OPTS[@]}" 
"-Dlog4j.configuration=log4j-monitor.properties")
     ;;
   gc|master|tserver|tracer)
     JAVA_OPTS=("${JAVA_OPTS[@]}" 
"-Dlog4j.configuration=log4j-service.properties")
     ;;
+{% endif %}
   *)
     # let log4j use its default behavior (log4j.xml, log4j.properties)
     true
diff --git a/ansible/roles/accumulo/templates/log4j2-service.properties 
b/ansible/roles/accumulo/templates/log4j2-service.properties
new file mode 100644
index 0000000..4e03025
--- /dev/null
+++ b/ansible/roles/accumulo/templates/log4j2-service.properties
@@ -0,0 +1,91 @@
+#
+# 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.
+#
+
+## Log4j2 file that configures logging for all Accumulo services
+## The system properties referenced below are configured by accumulo-env.sh
+
+status = info
+dest = err
+name = AccumuloServiceLoggingProperties
+monitorInterval = 30
+
+packages = org.apache.accumulo.monitor.util.logging
+
+property.filename = ${sys:accumulo.log.dir}/${sys:accumulo.application}
+
+appender.console.type = Console
+appender.console.name = STDERR
+appender.console.target = SYSTEM_ERR
+appender.console.layout.type = PatternLayout
+appender.console.layout.pattern = %d{ISO8601} [%-8c{2}] %-5p: %m%n
+appender.console.filter.threshold.type = ThresholdFilter
+appender.console.filter.threshold.level = info
+
+appender.rolling.type = RollingFile
+appender.rolling.name = LogFiles
+appender.rolling.fileName = ${filename}.log
+appender.rolling.filePattern = ${filename}-%d{MM-dd-yy-HH}-%i.log.gz
+appender.rolling.layout.type = PatternLayout
+appender.rolling.layout.pattern = %d{ISO8601} [%-8c{2}] %-5p: %m%n
+appender.rolling.policies.type = Policies
+appender.rolling.policies.time.type = TimeBasedTriggeringPolicy
+appender.rolling.policies.time.interval = 1
+appender.rolling.policies.time.modulate = true
+appender.rolling.policies.size.type = SizeBasedTriggeringPolicy
+appender.rolling.policies.size.size=100MB
+appender.rolling.strategy.type = DefaultRolloverStrategy
+appender.rolling.strategy.max = 10
+
+appender.audit.type = RollingFile
+appender.audit.name = AuditLogFiles
+appender.audit.fileName = ${filename}.audit
+appender.audit.filePattern = ${filename}-%d{MM-dd-yy-HH}-%i.audit.gz
+appender.audit.layout.type = PatternLayout
+appender.audit.layout.pattern = %d{ISO8601} [%-8c{2}] %-5p: %m%n
+appender.audit.policies.type = Policies
+appender.audit.policies.time.type = TimeBasedTriggeringPolicy
+appender.audit.policies.time.interval = 1
+appender.audit.policies.time.modulate = true
+appender.audit.policies.size.type = SizeBasedTriggeringPolicy
+appender.audit.policies.size.size=100MB
+appender.audit.strategy.type = DefaultRolloverStrategy
+appender.audit.strategy.max = 10
+
+appender.monitor.type = AccumuloMonitor
+appender.monitor.name = MonitorLog
+appender.monitor.filter.threshold.type = ThresholdFilter
+appender.monitor.filter.threshold.level = warn
+
+logger.zookeeper.name = org.apache.zookeeper
+logger.zookeeper.level = error
+
+logger.accumulo.name = org.apache.accumulo
+logger.accumulo.level = debug
+
+# uncomment for separate audit logs
+#logger.audit.name = org.apache.accumulo.audit
+#logger.audit.level = info
+#logger.audit.additivity = false
+#logger.audit.appenderRef.audit.ref = AuditLogFiles
+
+rootLogger.level = info
+rootLogger.appenderRef.console.ref = STDERR
+rootLogger.appenderRef.rolling.ref = LogFiles
+rootLogger.appenderRef.monitor.ref = MonitorLog
+
diff --git a/ansible/roles/accumulo/templates/log4j2.properties 
b/ansible/roles/accumulo/templates/log4j2.properties
new file mode 100644
index 0000000..6decfa4
--- /dev/null
+++ b/ansible/roles/accumulo/templates/log4j2.properties
@@ -0,0 +1,41 @@
+#
+# 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.
+#
+
+## Log4j2 file that configures logging for processes other than Accumulo 
services
+
+status = info
+dest = err
+name = AccumuloDefaultLoggingProperties
+monitorInterval = 30
+
+appender.console.type = Console
+appender.console.name = STDERR
+appender.console.target = SYSTEM_ERR
+appender.console.layout.type = PatternLayout
+appender.console.layout.pattern = %style{%d{ISO8601}}{dim,cyan} 
%style{[}{red}%style{%-8c{2}}{dim,blue}%style{]}{red} 
%highlight{%-5p}%style{:}{red} %m%n
+
+logger.shellaudit.name = org.apache.accumulo.shell.Shell.audit
+logger.shellaudit.level = warn
+
+logger.zookeeper.name = org.apache.zookeeper
+logger.zookeeper.level = error
+
+rootLogger.level = info
+rootLogger.appenderRef.console.ref = STDERR
+

Reply via email to