Skip to content

Commit

Permalink
[#75] Customize ActiveMQ Artemis log properties
Browse files Browse the repository at this point in the history
Set the system property log4j2.configurationFile to customize ActiveMQ
Artemis log properties.
  • Loading branch information
brusdev committed Sep 25, 2023
1 parent 7c99c1c commit 0f9bad0
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 9 deletions.
17 changes: 9 additions & 8 deletions modules/activemq-artemis-launch/added/launch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,14 @@ function configureJolokiaJVMAgent() {
fi
}

function configureLogging() {
instanceDir=$1
echo "Configure logging"
echo '' >> ${instanceDir}/etc/artemis.profile
echo 'JAVA_ARGS=" $JAVA_ARGS -Dlog4j2.configurationFile=$ARTEMIS_HOME/conf/log4j2.properties "' >> ${instanceDir}/etc/artemis.profile
echo '' >> ${instanceDir}/etc/artemis.profile
}

function injectMetricsPlugin() {
instanceDir=$1
echo "Adding artemis metrics plugin"
Expand All @@ -308,14 +316,6 @@ function checkBeforeRun() {
injectMetricsPlugin ${instanceDir}
fi
fi

if [[ "${JAVA_ARGS_APPEND}" == *"-Dlog4j2.configurationFile"* ]]; then
echo "There is a custom logger configuration defined in JAVA_ARGS_APPEND: ${JAVA_ARGS_APPEND}"
else
echo "Using default logging configuration(console only)"
defaultLoggingConfigFile=${instanceDir}/etc/log4j2.properties
sed -i "/rootLogger.appenderRef.log_file.ref = log_file/d" $defaultLoggingConfigFile
fi
}

function selectDelim {
Expand Down Expand Up @@ -669,6 +669,7 @@ function configure() {
appendConnectorsFromEnv ${instanceDir}
configureJAVA_ARGSMemory ${instanceDir}
configureJolokiaJVMAgent ${instanceDir}
configureLogging ${instanceDir}

if [ "$AMQ_ENABLE_MANAGEMENT_RBAC" = "false" ]; then
disableManagementRBAC ${instanceDir}
Expand Down
60 changes: 60 additions & 0 deletions modules/activemq-artemis-launch/added/log4j2.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# 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.

# Log4J 2 configuration

# Monitor config file every X seconds for updates
monitorInterval = 5

rootLogger.level = INFO
rootLogger.appenderRef.console.ref = console

logger.activemq.name=org.apache.activemq
logger.activemq.level=INFO

logger.artemis_server.name=org.apache.activemq.artemis.core.server
logger.artemis_server.level=INFO

logger.artemis_journal.name=org.apache.activemq.artemis.journal
logger.artemis_journal.level=INFO

logger.artemis_utils.name=org.apache.activemq.artemis.utils
logger.artemis_utils.level=INFO

# CriticalAnalyzer: If you have issues with the CriticalAnalyzer, setting this to TRACE would give
# you extra troubleshooting info, but do not use TRACE regularly as it would incur extra CPU usage.
logger.critical_analyzer.name=org.apache.activemq.artemis.utils.critical
logger.critical_analyzer.level=INFO

# Jetty logger levels
logger.jetty.name=org.eclipse.jetty
logger.jetty.level=WARN

# web console authenticator too verbose for impatient client
logger.authentication_filter.name=io.hawt.web.auth.AuthenticationFilter
logger.authentication_filter.level=ERROR

# Quorum related logger levels
logger.curator.name=org.apache.curator
logger.curator.level=WARN
logger.zookeeper.name=org.apache.zookeeper
logger.zookeeper.level=ERROR


# Console appender
appender.console.type=Console
appender.console.name=console
appender.console.layout.type=PatternLayout
appender.console.layout.pattern=%d %-5level [%logger] %msg%n
3 changes: 3 additions & 0 deletions modules/activemq-artemis-launch/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ cp -p ${SOURCES_DIR}/netty-tcnative*.jar \
cp -p $ADDED_DIR/jgroups-ping.xml \
${DEST}/conf/

cp -p $ADDED_DIR/log4j2.properties \
${DEST}/conf/

cp $ADDED_DIR/launch.sh \
${ADDED_DIR}/readinessProbe.sh \
${ADDED_DIR}/drain.sh \
Expand Down
2 changes: 1 addition & 1 deletion tests/features/basic.feature
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Feature: Basic
| AMQ_PASSWORD | admin |
Then check that port 61616 is open
Then run /home/jboss/broker/bin/artemis check queue --name TEST --produce 1000 --browse 1000 --consume 1000 --user admin --password admin in container and check its output contains Checks run: 3, Failures: 0, Errors: 0, Skipped: 0
Then run stat --printf="%s" /home/jboss/broker/log/artemis.log in container and immediately check its output for 0
Then file /home/jboss/broker/log/artemis.log should not exist

Scenario: Test if SNI checks are disabled
When container is started with env
Expand Down

0 comments on commit 0f9bad0

Please sign in to comment.