diff --git a/activemq-all/pom.xml b/activemq-all/pom.xml index 01630fa049..1e623dfe11 100644 --- a/activemq-all/pom.xml +++ b/activemq-all/pom.xml @@ -60,12 +60,8 @@ geronimo-annotation_1.0_spec - org.slf4j - slf4j-log4j12 - - - org.slf4j - jcl-over-slf4j + org.apache.logging.log4j + log4j-slf4j-impl @@ -109,9 +105,8 @@ org.apache.geronimo.specs:geronimo-j2ee-management_1.1_spec org.apache.geronimo.specs:geronimo-annotation_1.0_spec org.slf4j:slf4j-api - org.slf4j:slf4j-log4j12 + org.apache.logging:log4j-slf4j-impl org.slf4j:jcl-over-slf4j - log4j:log4j org.springframework:spring-core org.springframework:spring-beans org.springframework:spring-context @@ -347,15 +342,15 @@ true - org.slf4j - slf4j-log4j12 - ${slf4j-version} + org.apache.logging + log4j-slf4j-impl + ${log4j-version} sources true - log4j - log4j + org.apache.logging + log4j-api ${log4j-version} sources true diff --git a/activemq-all/src/main/resources/log4j.properties b/activemq-all/src/main/resources/log4j2.properties similarity index 58% rename from activemq-all/src/main/resources/log4j.properties rename to activemq-all/src/main/resources/log4j2.properties index 0cb38c4c4d..08ed0630c0 100644 --- a/activemq-all/src/main/resources/log4j.properties +++ b/activemq-all/src/main/resources/log4j2.properties @@ -19,25 +19,42 @@ # This file controls most of the logging in ActiveMQ which is mainly based around # the commons logging API. # -log4j.rootLogger=INFO, console -log4j.logger.org.apache.activemq.spring=WARN -log4j.logger.org.apache.activemq.web.handler=WARN -log4j.logger.org.springframework=WARN -log4j.logger.org.apache.xbean=WARN -log4j.logger.org.apache.camel=INFO -log4j.logger.org.eclipse.jetty=WARN +rootLogger.level=INFO +rootLogger.appenderRef.console.ref=Console +rootLogger.appenderRef.console.filter.threshold.type=ThresholdFilter +rootLogger.appenderRef.console.filter.threshold.level=INFO + +logger.spring.name=org.apache.activemq.spring +logger.spring.level=WARN + +logger.handler.name=org.apache.activemq.web.handler +logger.handler.level=WARN + +logger.springframework.name=org.springframework +logger.springframework.level=WARN + +logger.xbean.name=org.apache.xbean +logger.xbean.level=WARN + +logger.camel.name=org.apache.camel +logger.camel.level=INFO + +logger.jetty.name=org.eclipse.jetty +logger.jetty.level=WARN # When debugging or reporting problems to the ActiveMQ team, # comment out the above lines and uncomment the next. -#log4j.rootLogger=DEBUG, logfile, console +#rootLogger.level=DEBUG # Or for more fine grained debug logging uncomment one of these -#log4j.logger.org.apache.activemq=DEBUG -#log4j.logger.org.apache.camel=DEBUG +#logger.activemq.name=org.apache.activemq +#logger.activemq.level=DEBUG +#logger.camel.name=org.apache.camel +#logger.camel.level=DEBUG # Console appender -log4j.appender.console=org.apache.log4j.ConsoleAppender -log4j.appender.console.layout=org.apache.log4j.PatternLayout -log4j.appender.console.layout.ConversionPattern=%5p | %m%n -log4j.appender.console.threshold=INFO \ No newline at end of file +appender.console.type=Console +appender.console.name=Console +appender.console.layout.type=PatternLayout +appender.console.layout.pattern=%5p | %m%n \ No newline at end of file diff --git a/activemq-amqp/pom.xml b/activemq-amqp/pom.xml index e6fa92f247..c764f11c73 100644 --- a/activemq-amqp/pom.xml +++ b/activemq-amqp/pom.xml @@ -130,8 +130,8 @@ test - org.slf4j - slf4j-log4j12 + org.apache.logging.log4j + log4j-slf4j-impl test diff --git a/activemq-amqp/src/test/resources/log4j.properties b/activemq-amqp/src/test/resources/log4j.properties deleted file mode 100644 index 64d4fb0378..0000000000 --- a/activemq-amqp/src/test/resources/log4j.properties +++ /dev/null @@ -1,45 +0,0 @@ -# -# 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. -# - -# -# The logging properties used during tests.. -# -log4j.rootLogger=WARN, console, file -log4j.logger.org.apache.activemq=INFO -log4j.logger.org.apache.activemq.transport.amqp=DEBUG -log4j.logger.org.apache.activemq.transport.amqp.client.FRAMES=TRACE -log4j.logger.org.apache.activemq.transport.amqp.FRAMES=TRACE -log4j.logger.org.fusesource=INFO - -# Configure various level of detail for Qpid JMS logs. -log4j.logger.org.apache.qpid.jms=INFO -log4j.logger.org.apache.qpid.jms.provider=INFO -log4j.logger.org.apache.qpid.jms.provider.amqp=INFO -log4j.logger.org.apache.qpid.jms.provider.amqp.FRAMES=INFO - -# Console will only display warnings -log4j.appender.console=org.apache.log4j.ConsoleAppender -log4j.appender.console.layout=org.apache.log4j.PatternLayout -log4j.appender.console.layout.ConversionPattern=%d [%-15.15t] - %-5p %-25.30c{1} - %m%n -log4j.appender.console.threshold=TRACE - -# File appender will contain all info messages -log4j.appender.file=org.apache.log4j.FileAppender -log4j.appender.file.layout=org.apache.log4j.PatternLayout -log4j.appender.file.layout.ConversionPattern=%d [%-15.15t] - %-5p %-30.30c{1} - %m%n -log4j.appender.file.file=target/test.log -log4j.appender.file.append=true diff --git a/activemq-amqp/src/test/resources/log4j2-test.properties b/activemq-amqp/src/test/resources/log4j2-test.properties new file mode 100644 index 0000000000..9194a4ebc6 --- /dev/null +++ b/activemq-amqp/src/test/resources/log4j2-test.properties @@ -0,0 +1,74 @@ +# +# 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. +# + +# +# The logging properties used during tests +# +rootLogger.level=WARN + +rootLogger.appenderRef.console.ref=Console +rootLogger.appenderRef.console.filter.threshold.type=ThresholdFilter +rootLogger.appenderRef.console.filter.threshold.level=TRACE +rootLogger.appenderRef.logfile.ref=RollingFile + +logger.activemq.name=org.apache.activemq +logger.activemq.level=INFO + +logger.amqp.name=org.apache.activemq.transport.amqp +logger.amqp.level=DEBUG + +logger.clientframes.name=org.apache.activemq.transport.amqp.client.FRAMES +logger.clientframes.level=TRACE + +logger.frames.name=org.apache.activemq.transport.amqp.FRAMES +logger.frames.level=TRACE + +logger.fusesource.name=org.fusesource +logger.fusesource.level=INFO + +# Configure various level of detail for Qpid JMS logs. +logger.qpid.name=org.apache.qpid.jms +logger.qpid.level=INFO + +logger.qpidprovider.name=org.apache.qpid.jms.provider +logger.qpidprovider.level=INFO + +logger.qpidamqp.name=org.apache.qpid.jms.provider.amqp +logger.qpidamqp.level=INFO + +logger.qpidframes.name=org.apache.qpid.jms.provider.amqp.FRAMES +logger.qpidframes.level=INFO + +# Appender configuration + +# Console appender +appender.console.type=Console +appender.console.name=Console +appender.console.layout.type=PatternLayout +appender.console.layout.pattern=%d [%-15.15t] - %-5p %-25.30c{1} - %m%n + +# RollingFile appender +appender.logfile.type=RollingRandomAccessFile +appender.logfile.name=RollingFile +appender.logfile.fileName=target/test.log +appender.logfile.filePattern=target/test.log.%i +appender.logfile.append=true +appender.logfile.layout.type=PatternLayout +appender.logfile.layout.pattern=%d [%-15.15t] - %-5p %-30.30c{1} - %m%n +appender.logfile.policies.type=Policies +appender.logfile.policies.size.type=SizeBasedTriggeringPolicy +appender.logfile.policies.size.size=1MB \ No newline at end of file diff --git a/activemq-broker/pom.xml b/activemq-broker/pom.xml index 50386a7403..ea8ecac5f8 100644 --- a/activemq-broker/pom.xml +++ b/activemq-broker/pom.xml @@ -83,8 +83,13 @@ test - org.slf4j - slf4j-log4j12 + org.apache.logging.log4j + log4j-core + test + + + org.apache.logging.log4j + log4j-slf4j-impl test @@ -105,7 +110,6 @@ ${javase-javadoc-url} ${javaee-javadoc-url} - ${slf4j-javadoc-url} http://junit.sourceforge.net/javadoc/ ${basedir}/../etc/css/stylesheet.css diff --git a/activemq-broker/src/test/java/org/apache/activemq/util/DefaultTestAppender.java b/activemq-broker/src/test/java/org/apache/activemq/util/DefaultTestAppender.java index 97ca4b3f5d..b68c6b6bb4 100644 --- a/activemq-broker/src/test/java/org/apache/activemq/util/DefaultTestAppender.java +++ b/activemq-broker/src/test/java/org/apache/activemq/util/DefaultTestAppender.java @@ -17,34 +17,14 @@ package org.apache.activemq.util; -import org.apache.log4j.Appender; -import org.apache.log4j.Layout; -import org.apache.log4j.spi.ErrorHandler; -import org.apache.log4j.spi.Filter; +import org.apache.logging.log4j.core.Appender; +import org.apache.logging.log4j.core.ErrorHandler; +import org.apache.logging.log4j.core.Layout; +import org.apache.logging.log4j.core.LogEvent; public abstract class DefaultTestAppender implements Appender { String name = this.getClass().getSimpleName(); - - @Override - public void addFilter(Filter newFilter) { - - } - - @Override - public Filter getFilter() { - return null; - } - - @Override - public void clearFilters() { - - } - - @Override - public void close() { - - } @Override public String getName() { @@ -52,17 +32,12 @@ public abstract class DefaultTestAppender implements Appender { } @Override - public void setErrorHandler(ErrorHandler errorHandler) { - - } - - @Override - public ErrorHandler getErrorHandler() { + public ErrorHandler getHandler() { return null; } @Override - public void setLayout(Layout layout) { + public void setHandler(ErrorHandler handler) { } @@ -72,12 +47,42 @@ public abstract class DefaultTestAppender implements Appender { } @Override - public void setName(String name) { - this.name = name; + public void append(LogEvent event) { + } @Override - public boolean requiresLayout() { + public boolean ignoreExceptions() { + return true; + } + + @Override + public State getState() { + return null; + } + + @Override + public void initialize() { + + } + + @Override + public void start() { + + } + + @Override + public void stop() { + + } + + @Override + public boolean isStarted() { + return false; + } + + @Override + public boolean isStopped() { return false; } } diff --git a/activemq-broker/src/test/resources/log4j.properties b/activemq-broker/src/test/resources/log4j.properties deleted file mode 100644 index 7cc19418fd..0000000000 --- a/activemq-broker/src/test/resources/log4j.properties +++ /dev/null @@ -1,42 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- - -# -# The logging properties used during tests.. -# -log4j.rootLogger=INFO, out, stdout - -#log4j.logger.org.apache.activemq.broker.scheduler=DEBUG -#log4j.logger.org.apache.activemq.network.DemandForwardingBridgeSupport=DEBUG -#log4j.logger.org.apache.activemq.transport.failover=TRACE -#log4j.logger.org.apache.activemq.store.jdbc=TRACE -#log4j.logger.org.apache.activemq.broker.region.cursors.AbstractStoreCursor=DEBUG -#log4j.logger.org.apache.activemq.store.jdbc.JDBCMessageStore=DEBUG - -# CONSOLE appender not used by default -log4j.appender.stdout=org.apache.log4j.ConsoleAppender -log4j.appender.stdout.layout=org.apache.log4j.PatternLayout -log4j.appender.stdout.layout.ConversionPattern=%d [%-15.15t] - %-5p %-30.30c{1} - %m%n -#log4j.appender.stdout.layout.ConversionPattern=%d [%-15.15t] - %-5p %-30.30c{1} - %-10.10X{activemq.broker} %-20.20X{activemq.connector} %-10.10X{activemq.destination} - %m%n - -# File appender -log4j.appender.out=org.apache.log4j.FileAppender -log4j.appender.out.layout=org.apache.log4j.PatternLayout -log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] - %-5p %-30.30c{1} - %m%n -#log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] - %-5p %-30.30c{1} - %-10.10X{activemq.broker} %-20.20X{activemq.connector} %-10.10X{activemq.destination} - %m%n -log4j.appender.out.file=target/activemq-test.log -log4j.appender.out.append=true diff --git a/activemq-broker/src/test/resources/log4j2-test.properties b/activemq-broker/src/test/resources/log4j2-test.properties new file mode 100644 index 0000000000..220bf0ca49 --- /dev/null +++ b/activemq-broker/src/test/resources/log4j2-test.properties @@ -0,0 +1,57 @@ +## --------------------------------------------------------------------------- +## 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. +## --------------------------------------------------------------------------- + +# +# The logging properties used during tests +# +rootLogger.level=INFO + +rootLogger.appenderRef.console.ref=Console +rootLogger.appenderRef.logfile.ref=RollingFile + +#logger.scheduler.name=org.apache.activemq.broker.scheduler +#logger.scheduler.level=DEBUG +#logger.network.name=org.apache.activemq.network.DemandForwardingBridgeSupport +#logger.network.level=DEBUG +#logger.failover.name=org.apache.activemq.transport.failover +#logger.failover.level=TRACE +#logger.jdbc.name=org.apache.activemq.store.jdbc +#logger.jdbc.level=TRACE +#logger.cursors.name=org.apache.activemq.broker.region.cursors.AbstractStoreCursor +#logger.cursors.level=DEBUG + +# Appender configuration + +# Console appender +appender.console.type=Console +appender.console.name=Console +appender.console.layout.type=PatternLayout +appender.console.layout.pattern=%d [%-15.15t] - %-5p %-30.30c{1} - %m%n +#appender.console.layout.pattern=%d [%-15.15t] - %-5p %-30.30c{1} - %-10.10X{activemq.broker} %-20.20X{activemq.connector} %-10.10X{activemq.destination} - %m%n + +# RollingFile appender +appender.logfile.type=RollingRandomAccessFile +appender.logfile.name=RollingFile +appender.logfile.fileName=target/activemq-test.log +appender.logfile.filePattern=target/activemq-test.log.%i +appender.logfile.append=true +appender.logfile.layout.type=PatternLayout +appender.logfile.layout.pattern=%d [%-15.15t] - %-5p %-30.30c{1} - %m%n +#appender.logfile.layout.pattern=%d [%-15.15t] - %-5p %-30.30c{1} - %-10.10X{activemq.broker} %-20.20X{activemq.connector} %-10.10X{activemq.destination} - %m%n +appender.logfile.policies.type=Policies +appender.logfile.policies.size.type=SizeBasedTriggeringPolicy +appender.logfile.policies.size.size=1MB diff --git a/activemq-client/pom.xml b/activemq-client/pom.xml index ae9f394215..aab0911b9c 100644 --- a/activemq-client/pom.xml +++ b/activemq-client/pom.xml @@ -80,8 +80,8 @@ test - org.slf4j - slf4j-log4j12 + org.apache.logging.log4j + log4j-slf4j-impl test diff --git a/activemq-client/src/test/resources/log4j.properties b/activemq-client/src/test/resources/log4j.properties deleted file mode 100644 index 7cc19418fd..0000000000 --- a/activemq-client/src/test/resources/log4j.properties +++ /dev/null @@ -1,42 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- - -# -# The logging properties used during tests.. -# -log4j.rootLogger=INFO, out, stdout - -#log4j.logger.org.apache.activemq.broker.scheduler=DEBUG -#log4j.logger.org.apache.activemq.network.DemandForwardingBridgeSupport=DEBUG -#log4j.logger.org.apache.activemq.transport.failover=TRACE -#log4j.logger.org.apache.activemq.store.jdbc=TRACE -#log4j.logger.org.apache.activemq.broker.region.cursors.AbstractStoreCursor=DEBUG -#log4j.logger.org.apache.activemq.store.jdbc.JDBCMessageStore=DEBUG - -# CONSOLE appender not used by default -log4j.appender.stdout=org.apache.log4j.ConsoleAppender -log4j.appender.stdout.layout=org.apache.log4j.PatternLayout -log4j.appender.stdout.layout.ConversionPattern=%d [%-15.15t] - %-5p %-30.30c{1} - %m%n -#log4j.appender.stdout.layout.ConversionPattern=%d [%-15.15t] - %-5p %-30.30c{1} - %-10.10X{activemq.broker} %-20.20X{activemq.connector} %-10.10X{activemq.destination} - %m%n - -# File appender -log4j.appender.out=org.apache.log4j.FileAppender -log4j.appender.out.layout=org.apache.log4j.PatternLayout -log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] - %-5p %-30.30c{1} - %m%n -#log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] - %-5p %-30.30c{1} - %-10.10X{activemq.broker} %-20.20X{activemq.connector} %-10.10X{activemq.destination} - %m%n -log4j.appender.out.file=target/activemq-test.log -log4j.appender.out.append=true diff --git a/activemq-client/src/test/resources/log4j2-test.properties b/activemq-client/src/test/resources/log4j2-test.properties new file mode 100644 index 0000000000..16e26c5226 --- /dev/null +++ b/activemq-client/src/test/resources/log4j2-test.properties @@ -0,0 +1,55 @@ +## --------------------------------------------------------------------------- +## 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. +## --------------------------------------------------------------------------- + +# +# The logging properties used during tests +# +rootLogger.level=INFO + +rootLogger.appenderRef.console.ref=Console +rootLogger.appenderRef.logfile.ref=RollingFile + +#logger.scheduler.name=org.apache.activemq.broker.scheduler +#logger.scheduler.level=DEBUG +#logger.network.name=org.apache.activemq.network.DemandForwardingBridgeSupport +#logger.network.level=DEBUG +#logger.failover.name=org.apache.activemq.transport.failover +#logger.failover.level=TRACE +#logger.jdbc.name=org.apache.activemq.store.jdbc +#logger.jdbc.level=TRACE +#logger.cursors.name=org.apache.activemq.broker.region.cursors.AbstractStoreCursor +#logger.cursors.level=DEBUG + +# Console appender +appender.console.type=Console +appender.console.name=Console +appender.console.layout.type=PatternLayout +appender.console.layout.pattern=%d [%-15.15t] - %-5p %-30.30c{1} - %m%n +#appender.console.layout.pattern=%d [%-15.15t] - %-5p %-30.30c{1} - %-10.10X{activemq.broker} %-20.20X{activemq.connector} %-10.10X{activemq.destination} - %m%n + +# RollingFile appender +appender.logfile.type=RollingRandomAccessFile +appender.logfile.name=RollingFile +appender.logfile.fileName=target/activemq-test.log +appender.logfile.filePattern=target/activemq-test.log.%i +appender.logfile.append=true +appender.logfile.layout.type=PatternLayout +appender.logfile.layout.pattern=%d [%-15.15t] - %-5p %-30.30c{1} - %m%n +#appender.logfile.layout.pattern=%d [%-15.15t] - %-5p %-30.30c{1} - %-10.10X{activemq.broker} %-20.20X{activemq.connector} %-10.10X{activemq.destination} - %m%n +appender.logfile.policies.type=Policies +appender.logfile.policies.size.type=SizeBasedTriggeringPolicy +appender.logfile.policies.size.size=1MB diff --git a/activemq-console/pom.xml b/activemq-console/pom.xml index 55726f8934..b4bf1c269d 100644 --- a/activemq-console/pom.xml +++ b/activemq-console/pom.xml @@ -104,13 +104,13 @@ test - org.slf4j - slf4j-log4j12 + org.apache.logging.log4j + log4j-slf4j-impl test - log4j - log4j + org.apache.logging.log4j + log4j-core test @@ -165,10 +165,10 @@ org.apache.activemq.default.directory.prefix target/ - - diff --git a/activemq-console/src/main/java/org/apache/activemq/console/Main.java b/activemq-console/src/main/java/org/apache/activemq/console/Main.java index 4e2db4f1e2..a6d507acca 100644 --- a/activemq-console/src/main/java/org/apache/activemq/console/Main.java +++ b/activemq-console/src/main/java/org/apache/activemq/console/Main.java @@ -67,7 +67,7 @@ public class Main { // Parse for extension directory option app.parseExtensions(tokens); - // lets add the conf directory first, to find the log4j.properties just in case its not + // lets add the conf directory first, to find the log4j2-test.properties just in case its not // in the activemq.classpath system property or some jar incorrectly includes one File confDir = app.getActiveMQConfig(); app.addClassPath(confDir); diff --git a/activemq-console/src/test/resources/log4j.properties b/activemq-console/src/test/resources/log4j.properties deleted file mode 100644 index a0f2ca0f20..0000000000 --- a/activemq-console/src/test/resources/log4j.properties +++ /dev/null @@ -1,66 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- - -# -# The logging properties used during tests.. -# -log4j.rootLogger=DEBUG, stdout, out -log4j.logger.org.apache.activemq.spring=WARN - -log4j.logger.org.apache.activemq=INFO -log4j.logger.org.apache.activemq.console.command.AMQJournalToolTest=DEBUG - -# CONSOLE appender, not used by default -log4j.appender.stdout=org.apache.log4j.ConsoleAppender -log4j.appender.stdout.layout=org.apache.log4j.PatternLayout -log4j.appender.stdout.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n - - -# File appender -log4j.appender.out=org.apache.log4j.FileAppender -log4j.appender.out.layout=org.apache.log4j.PatternLayout -log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] - %-5p %-30.30c{1} - %m%n -log4j.appender.out.file=target/activemq-test.log -log4j.appender.out.append=true - - -# Example of properties to make use of new logging options -# -#log4j.rootLogger=INFO, A -#log4j.additivity.org.apache.activemq.transport.TransportLogger=false -#log4j.logger.org.apache.activemq.transport.TransportLogger=DEBUG, B -# -# CONSOLE appender, not used by default -#log4j.appender.stdout=org.apache.log4j.ConsoleAppender -#log4j.appender.stdout.layout=org.apache.log4j.PatternLayout -#log4j.appender.stdout.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n -# -# File appender for normal output -#log4j.appender.A=org.apache.log4j.FileAppender -#log4j.appender.A.File=applog -#log4j.appender.A.BufferedIO=false -#log4j.appender.A.layout=org.apache.log4j.PatternLayout -#log4j.appender.A.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n -# -# File appender for transport level logging output -#log4j.appender.B=org.apache.log4j.FileAppender -#log4j.appender.B.File=transportlog -#log4j.appender.B.BufferedIO=false -#log4j.appender.B.layout=org.apache.log4j.PatternLayout -#log4j.appender.B.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n -# -# End of example \ No newline at end of file diff --git a/activemq-console/src/test/resources/log4j2-test.properties b/activemq-console/src/test/resources/log4j2-test.properties new file mode 100644 index 0000000000..b2214cc026 --- /dev/null +++ b/activemq-console/src/test/resources/log4j2-test.properties @@ -0,0 +1,52 @@ +## --------------------------------------------------------------------------- +## 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. +## --------------------------------------------------------------------------- + +# +# The logging properties used during tests +# +rootLogger.level=DEBUG + +rootLogger.appenderRef.console.ref=Console +rootLogger.appenderRef.logfile.ref=RollingFile + +logger.spring.name=org.apache.activemq.spring +logger.spring.level=WARN + +logger.activemq.name=org.apache.activemq +logger.activemq.level=INFO + +logger.console.name=org.apache.activemq.console.command.AMQJournalToolTest +logger.console.level=DEBUG + +# Console appender +appender.console.type=Console +appender.console.name=Console +appender.console.layout.type=PatternLayout +appender.console.layout.pattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n + +# RollingFile appender +appender.logfile.type=RollingRandomAccessFile +appender.logfile.name=RollingFile +appender.logfile.fileName=target/activemq-test.log +appender.logfile.filePattern=target/activemq-test.log.%i +appender.logfile.append=true +appender.logfile.layout.type=PatternLayout +appender.logfile.layout.pattern=%d [%-15.15t] - %-5p %-30.30c{1} - %m%n +appender.logfile.policies.type=Policies +appender.logfile.policies.size.type=SizeBasedTriggeringPolicy +appender.logfile.policies.size.size=1MB + diff --git a/activemq-http/pom.xml b/activemq-http/pom.xml index 36f5467671..8b66104744 100644 --- a/activemq-http/pom.xml +++ b/activemq-http/pom.xml @@ -108,8 +108,8 @@ true - org.slf4j - slf4j-log4j12 + org.apache.logging.log4j + log4j-slf4j-impl test diff --git a/activemq-http/src/test/resources/log4j.properties b/activemq-http/src/test/resources/log4j.properties deleted file mode 100644 index 2aabf97d35..0000000000 --- a/activemq-http/src/test/resources/log4j.properties +++ /dev/null @@ -1,47 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- - -# -# The logging properties used during tests.. -# -log4j.rootLogger=INFO, out, stdout - -log4j.logger.org.apache.activemq.transport.ws=TRACE -log4j.logger.org.apache.activemq.transport.http=DEBUG -log4j.logger.org.apache.activemq.transport.amqp=TRACE -log4j.logger.org.apache.activemq.transport.amqp.FRAMES=TRACE - -#log4j.logger.org.apache.activemq.broker.scheduler=DEBUG -#log4j.logger.org.apache.activemq.network.DemandForwardingBridgeSupport=DEBUG -#log4j.logger.org.apache.activemq.transport.failover=TRACE -#log4j.logger.org.apache.activemq.store.jdbc=TRACE -#log4j.logger.org.apache.activemq.broker.region.cursors.AbstractStoreCursor=DEBUG -#log4j.logger.org.apache.activemq.store.jdbc.JDBCMessageStore=DEBUG - -# CONSOLE appender not used by default -log4j.appender.stdout=org.apache.log4j.ConsoleAppender -log4j.appender.stdout.layout=org.apache.log4j.PatternLayout -log4j.appender.stdout.layout.ConversionPattern=%d [%-15.15t] - %-5p %-30.30c{1} - %m%n -#log4j.appender.stdout.layout.ConversionPattern=%d [%-15.15t] - %-5p %-30.30c{1} - %-10.10X{activemq.broker} %-20.20X{activemq.connector} %-10.10X{activemq.destination} - %m%n - -# File appender -log4j.appender.out=org.apache.log4j.FileAppender -log4j.appender.out.layout=org.apache.log4j.PatternLayout -log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] - %-5p %-30.30c{1} - %m%n -#log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] - %-5p %-30.30c{1} - %-10.10X{activemq.broker} %-20.20X{activemq.connector} %-10.10X{activemq.destination} - %m%n -log4j.appender.out.file=target/activemq-test.log -log4j.appender.out.append=true diff --git a/activemq-http/src/test/resources/log4j2-test.properties b/activemq-http/src/test/resources/log4j2-test.properties new file mode 100644 index 0000000000..8eed9af13e --- /dev/null +++ b/activemq-http/src/test/resources/log4j2-test.properties @@ -0,0 +1,67 @@ +## --------------------------------------------------------------------------- +## 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. +## --------------------------------------------------------------------------- + +# +# The logging properties used during tests +# +rootLogger.level=INFO + +rootLogger.appenderRef.console.ref=Console +rootLogger.appenderRef.logfile.ref=RollingFile + +logger.transportws.name=org.apache.activemq.transport.ws +logger.transportws.level=TRACE + +logger.transporthttp.name=org.apache.activemq.transport.http +logger.transporthttp.level=DEBUG + +logger.transportamqp.name=org.apache.activemq.transport.amqp +logger.transportamqp.level=TRACE + +logger.frames.name=org.apache.activemq.transport.amqp.FRAMES +logger.frames.level=TRACE + +#logger.scheduler.name=org.apache.activemq.broker.scheduler +#logger.scheduler.level=DEBUG +#logger.network.name=org.apache.activemq.network.DemandForwardingBridgeSupport +#logger.network.level=DEBUG +#logger.failover.name=org.apache.activemq.transport.failover +#logger.failover.level=TRACE +#logger.jdbc.name=org.apache.activemq.store.jdbc +#logger.jdbc.level=TRACE +#logger.cursors.name=org.apache.activemq.broker.region.cursors.AbstractStoreCursor +#logger.cursors.level=DEBUG + +# Console appender +appender.console.type=Console +appender.console.name=Console +appender.console.layout.type=PatternLayout +appender.console.layout.pattern=%d [%-15.15t] - %-5p %-30.30c{1} - %m%n +#appender.console.layout.pattern=%d [%-15.15t] - %-5p %-30.30c{1} - %-10.10X{activemq.broker} %-20.20X{activemq.connector} %-10.10X{activemq.destination} - %m%n + +# RollingFile appender +appender.logfile.type=RollingRandomAccessFile +appender.logfile.name=RollingFile +appender.logfile.fileName=target/activemq-test.log +appender.logfile.filePattern=target/activemq-test.log.%i +appender.logfile.append=true +appender.logfile.layout.type=PatternLayout +appender.logfile.layout.pattern=%d [%-15.15t] - %-5p %-30.30c{1} - %m%n +#appender.logfile.layout.pattern=%d [%-15.15t] - %-5p %-30.30c{1} - %-10.10X{activemq.broker} %-20.20X{activemq.connector} %-10.10X{activemq.destination} - %m%n +appender.logfile.policies.type=Policies +appender.logfile.policies.size.type=SizeBasedTriggeringPolicy +appender.logfile.policies.size.size=1MB diff --git a/activemq-itests-spring31/pom.xml b/activemq-itests-spring31/pom.xml index bca914b14e..ca814b3610 100644 --- a/activemq-itests-spring31/pom.xml +++ b/activemq-itests-spring31/pom.xml @@ -73,13 +73,13 @@ test - org.slf4j - slf4j-log4j12 + org.apache.logging.log4j + log4j-slf4j-impl test - log4j - log4j + org.apache.logging.log4j + log4j-core test diff --git a/activemq-jaas/pom.xml b/activemq-jaas/pom.xml index 80b243676e..8137437e95 100644 --- a/activemq-jaas/pom.xml +++ b/activemq-jaas/pom.xml @@ -87,6 +87,12 @@ apacheds-server-integ ${directory-version} test + + + log4j + log4j + + junit @@ -100,8 +106,8 @@ test - log4j - log4j + org.apache.logging.log4j + log4j-core test @@ -109,8 +115,8 @@ slf4j-api - org.slf4j - slf4j-log4j12 + org.apache.logging.log4j + log4j-slf4j-impl test diff --git a/activemq-jaas/src/test/resources/log4j.properties b/activemq-jaas/src/test/resources/log4j.properties deleted file mode 100644 index 5d00c973a2..0000000000 --- a/activemq-jaas/src/test/resources/log4j.properties +++ /dev/null @@ -1,36 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- - -# -# The logging properties used during tests.. -# -log4j.rootLogger=INFO, out, stdout - -log4j.logger.org.apache.activemq=INFO -#log4j.logger.org.apache.activemq.jaas.LDAPLoginModule=DEBUG - -# CONSOLE appender not used by default -log4j.appender.stdout=org.apache.log4j.ConsoleAppender -log4j.appender.stdout.layout=org.apache.log4j.PatternLayout -log4j.appender.stdout.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n - -# File appender -log4j.appender.out=org.apache.log4j.FileAppender -log4j.appender.out.layout=org.apache.log4j.PatternLayout -log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n -log4j.appender.out.file=target/activemq-test.log -log4j.appender.out.append=true diff --git a/activemq-jaas/src/test/resources/log4j2-test.properties b/activemq-jaas/src/test/resources/log4j2-test.properties new file mode 100644 index 0000000000..edecc0e481 --- /dev/null +++ b/activemq-jaas/src/test/resources/log4j2-test.properties @@ -0,0 +1,48 @@ +## --------------------------------------------------------------------------- +## 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. +## --------------------------------------------------------------------------- + +# +# The logging properties used during tests +# +rootLogger.level=INFO + +rootLogger.appenderRef.console.ref=Console +rootLogger.appenderRef.logfile.ref=RollingFile + +logger.activemq.name=org.apache.activemq +logger.activemq.level=INFO + +#logger.jaas.name=org.apache.activemq.jaas.LDAPLoginModule +#logger.jaas.level=DEBUG + +# Console appender +appender.console.type=Console +appender.console.name=Console +appender.console.layout.type=PatternLayout +appender.console.layout.pattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n + +# RollingFile appender +appender.logfile.type=RollingRandomAccessFile +appender.logfile.name=RollingFile +appender.logfile.fileName=target/activemq-test.log +appender.logfile.filePattern=target/activemq-test.log.%i +appender.logfile.append=true +appender.logfile.layout.type=PatternLayout +appender.logfile.layout.pattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n +appender.logfile.policies.type=Policies +appender.logfile.policies.size.type=SizeBasedTriggeringPolicy +appender.logfile.policies.size.size=1MB diff --git a/activemq-jdbc-store/pom.xml b/activemq-jdbc-store/pom.xml index 285a4751a9..30c4dc35d3 100644 --- a/activemq-jdbc-store/pom.xml +++ b/activemq-jdbc-store/pom.xml @@ -79,8 +79,8 @@ test - org.slf4j - slf4j-log4j12 + org.apache.logging.log4j + log4j-slf4j-impl test @@ -114,7 +114,7 @@ org.apache.activemq.default.directory.prefix target/ - diff --git a/activemq-jdbc-store/src/test/java/org/apache/activemq/store/jdbc/adapter/DefaultJDBCAdapterDoCreateTablesTest.java b/activemq-jdbc-store/src/test/java/org/apache/activemq/store/jdbc/adapter/CommitsTheTransactionTest.java similarity index 52% rename from activemq-jdbc-store/src/test/java/org/apache/activemq/store/jdbc/adapter/DefaultJDBCAdapterDoCreateTablesTest.java rename to activemq-jdbc-store/src/test/java/org/apache/activemq/store/jdbc/adapter/CommitsTheTransactionTest.java index 08f31f7fa7..4cf8548659 100644 --- a/activemq-jdbc-store/src/test/java/org/apache/activemq/store/jdbc/adapter/DefaultJDBCAdapterDoCreateTablesTest.java +++ b/activemq-jdbc-store/src/test/java/org/apache/activemq/store/jdbc/adapter/CommitsTheTransactionTest.java @@ -16,8 +16,6 @@ */ package org.apache.activemq.store.jdbc.adapter; -import static org.apache.log4j.Level.DEBUG; -import static org.apache.log4j.Level.WARN; import static org.junit.Assert.assertEquals; import static org.mockito.Answers.RETURNS_DEEP_STUBS; import static org.mockito.Mockito.inOrder; @@ -33,12 +31,13 @@ import java.util.List; import org.apache.activemq.store.jdbc.Statements; import org.apache.activemq.store.jdbc.TransactionContext; -import org.apache.activemq.util.DefaultTestAppender; -import org.apache.log4j.Level; -import org.apache.log4j.Logger; -import org.apache.log4j.spi.LoggingEvent; -import org.junit.After; -import org.junit.Before; +import org.apache.logging.log4j.Level; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.core.LogEvent; +import org.apache.logging.log4j.core.appender.AbstractAppender; +import org.apache.logging.log4j.core.config.Property; +import org.apache.logging.log4j.core.filter.AbstractFilter; +import org.apache.logging.log4j.core.layout.MessageLayout; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.InOrder; @@ -46,7 +45,7 @@ import org.mockito.Mock; import org.mockito.runners.MockitoJUnitRunner; @RunWith(MockitoJUnitRunner.class) -public class DefaultJDBCAdapterDoCreateTablesTest { +public class CommitsTheTransactionTest { private static final String CREATE_STATEMENT1 = "createStatement1"; private static final String CREATE_STATEMENT2 = "createStatement2"; @@ -57,7 +56,7 @@ public class DefaultJDBCAdapterDoCreateTablesTest { private DefaultJDBCAdapter defaultJDBCAdapter; - private List loggingEvents = new ArrayList<>(); + private List loggingEvents = new ArrayList<>(); @Mock private TransactionContext transactionContext; @@ -74,18 +73,19 @@ public class DefaultJDBCAdapterDoCreateTablesTest { @Mock private Statement statement1, statement2; - @Before - public void setUp() throws IOException, SQLException { - DefaultTestAppender appender = new DefaultTestAppender() { + @Test + public void commitsTheTransactionWhenAutoCommitIsDisabled() throws SQLException, IOException { + final var logger = org.apache.logging.log4j.core.Logger.class.cast(LogManager.getRootLogger()); + final var appender = new AbstractAppender("testAppender", new AbstractFilter() {}, new MessageLayout(), false, new Property[0]) { @Override - public void doAppend(LoggingEvent event) { - loggingEvents.add(event); + public void append(LogEvent event) { + loggingEvents.add(event.toImmutable()); } }; - Logger rootLogger = Logger.getRootLogger(); - rootLogger.setLevel(Level.DEBUG); - rootLogger.addAppender(appender); + appender.start(); + logger.get().addAppender(appender, Level.DEBUG, new AbstractFilter() {}); + logger.addAppender(appender); defaultJDBCAdapter = new DefaultJDBCAdapter(); defaultJDBCAdapter.statements = statements; @@ -95,62 +95,7 @@ public class DefaultJDBCAdapterDoCreateTablesTest { when(connection.getMetaData().getTables(null, null, this.statements.getFullMessageTableName(),new String[] { "TABLE" })).thenReturn(resultSet); when(connection.createStatement()).thenReturn(statement1, statement2); when(connection.getAutoCommit()).thenReturn(true); - } - @After - public void tearDown() { - loggingEvents = new ArrayList<>(); - } - - @Test - public void createsTheTablesWhenNoMessageTableExistsAndLogsSqlExceptionsInWarnLevel() throws IOException, SQLException { - when(resultSet.next()).thenReturn(false); - when(statement2.execute(CREATE_STATEMENT2)).thenThrow(new SQLException(MY_REASON, SQL_STATE, VENDOR_CODE)); - - defaultJDBCAdapter.doCreateTables(transactionContext); - - InOrder inOrder = inOrder(resultSet, connection, statement1, statement2); - inOrder.verify(resultSet).next(); - inOrder.verify(resultSet).close(); - inOrder.verify(connection).createStatement(); - inOrder.verify(statement1).execute(CREATE_STATEMENT1); - inOrder.verify(statement1).close(); - inOrder.verify(connection).createStatement(); - inOrder.verify(statement2).execute(CREATE_STATEMENT2); - inOrder.verify(statement2).close(); - - assertEquals(4, loggingEvents.size()); - assertLog(0, DEBUG, "Executing SQL: " + CREATE_STATEMENT1); - assertLog(1, DEBUG, "Executing SQL: " + CREATE_STATEMENT2); - assertLog(2, WARN, "Could not create JDBC tables; they could already exist. Failure was: " + CREATE_STATEMENT2 + " Message: " + MY_REASON + " SQLState: " + SQL_STATE + " Vendor code: " + VENDOR_CODE); - assertLog(3, WARN, "Failure details: " + MY_REASON); - } - - @Test - public void triesTocreateTheTablesWhenMessageTableExistsAndLogsSqlExceptionsInDebugLevel() throws SQLException, IOException { - when(resultSet.next()).thenReturn(true); - when(statement1.execute(CREATE_STATEMENT1)).thenThrow(new SQLException(MY_REASON, SQL_STATE, VENDOR_CODE)); - - defaultJDBCAdapter.doCreateTables(transactionContext); - - InOrder inOrder = inOrder(resultSet, connection, statement1, statement2); - inOrder.verify(resultSet).next(); - inOrder.verify(resultSet).close(); - inOrder.verify(connection).createStatement(); - inOrder.verify(statement1).execute(CREATE_STATEMENT1); - inOrder.verify(statement1).close(); - inOrder.verify(connection).createStatement(); - inOrder.verify(statement2).execute(CREATE_STATEMENT2); - inOrder.verify(statement2).close(); - - assertEquals(3, loggingEvents.size()); - assertLog(0, DEBUG, "Executing SQL: " + CREATE_STATEMENT1); - assertLog(1, DEBUG, "Could not create JDBC tables; The message table already existed. Failure was: " + CREATE_STATEMENT1 + " Message: " + MY_REASON + " SQLState: " + SQL_STATE + " Vendor code: " + VENDOR_CODE); - assertLog(2, DEBUG, "Executing SQL: " + CREATE_STATEMENT2); - } - - @Test - public void commitsTheTransactionWhenAutoCommitIsDisabled() throws SQLException, IOException { when(connection.getAutoCommit()).thenReturn(false); when(resultSet.next()).thenReturn(false); @@ -169,13 +114,15 @@ public class DefaultJDBCAdapterDoCreateTablesTest { inOrder.verify(statement2).close(); assertEquals(2, loggingEvents.size()); - assertLog(0, DEBUG, "Executing SQL: " + CREATE_STATEMENT1); - assertLog(1, DEBUG, "Executing SQL: " + CREATE_STATEMENT2); + assertLog(0, Level.DEBUG, "Executing SQL: " + CREATE_STATEMENT1); + assertLog(1, Level.DEBUG, "Executing SQL: " + CREATE_STATEMENT2); + + loggingEvents = new ArrayList<>(); } private void assertLog(int messageNumber, Level level, String message) { - LoggingEvent loggingEvent = loggingEvents.get(messageNumber); + LogEvent loggingEvent = loggingEvents.get(messageNumber); assertEquals(level, loggingEvent.getLevel()); - assertEquals(message, loggingEvent.getMessage()); + assertEquals(message, loggingEvent.getMessage().getFormattedMessage()); } } \ No newline at end of file diff --git a/activemq-jdbc-store/src/test/java/org/apache/activemq/store/jdbc/adapter/JDBCTablesExistsTest.java b/activemq-jdbc-store/src/test/java/org/apache/activemq/store/jdbc/adapter/JDBCTablesExistsTest.java new file mode 100644 index 0000000000..27fedc5497 --- /dev/null +++ b/activemq-jdbc-store/src/test/java/org/apache/activemq/store/jdbc/adapter/JDBCTablesExistsTest.java @@ -0,0 +1,127 @@ +/** + * 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. + */ +package org.apache.activemq.store.jdbc.adapter; + +import org.apache.activemq.store.jdbc.Statements; +import org.apache.activemq.store.jdbc.TransactionContext; +import org.apache.logging.log4j.Level; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.core.LogEvent; +import org.apache.logging.log4j.core.appender.AbstractAppender; +import org.apache.logging.log4j.core.config.Property; +import org.apache.logging.log4j.core.filter.AbstractFilter; +import org.apache.logging.log4j.core.layout.MessageLayout; +import org.junit.runner.RunWith; +import org.mockito.InOrder; +import org.mockito.Mock; +import org.mockito.runners.MockitoJUnitRunner; + +import java.io.IOException; +import java.sql.Connection; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.util.ArrayList; +import java.util.List; + +import static org.junit.Assert.assertEquals; +import static org.mockito.Answers.RETURNS_DEEP_STUBS; +import static org.mockito.Mockito.inOrder; +import static org.mockito.Mockito.when; + +@RunWith(MockitoJUnitRunner.class) +public class JDBCTablesExistsTest { + + private static final String CREATE_STATEMENT1 = "createStatement1"; + private static final String CREATE_STATEMENT2 = "createStatement2"; + private static final String[] CREATE_STATEMENTS = new String[]{CREATE_STATEMENT1, CREATE_STATEMENT2}; + private static final int VENDOR_CODE = 1; + private static final String SQL_STATE = "SqlState"; + private static final String MY_REASON = "MyReason"; + + private DefaultJDBCAdapter defaultJDBCAdapter; + + private List loggingEvents = new ArrayList<>(); + + @Mock + private TransactionContext transactionContext; + + @Mock(answer = RETURNS_DEEP_STUBS) + private Connection connection; + + @Mock + private Statements statements; + + @Mock + private ResultSet resultSet; + + @Mock + private Statement statement1, statement2; + + @org.junit.Test + public void createsTheTablesWhenNoMessageTableExistsAndLogsSqlExceptionsInWarnLevel() throws IOException, SQLException { + final var logger = org.apache.logging.log4j.core.Logger.class.cast(LogManager.getRootLogger()); + final var appender = new AbstractAppender("testAppender", new AbstractFilter() {}, new MessageLayout(), false, new Property[0]) { + @Override + public void append(LogEvent event) { + loggingEvents.add(event.toImmutable()); + } + }; + appender.start(); + + logger.get().addAppender(appender, Level.DEBUG, new AbstractFilter() {}); + logger.addAppender(appender); + + defaultJDBCAdapter = new DefaultJDBCAdapter(); + defaultJDBCAdapter.statements = statements; + + when(statements.getCreateSchemaStatements()).thenReturn(CREATE_STATEMENTS); + when(transactionContext.getConnection()).thenReturn(connection); + when(connection.getMetaData().getTables(null, null, this.statements.getFullMessageTableName(),new String[] { "TABLE" })).thenReturn(resultSet); + when(connection.createStatement()).thenReturn(statement1, statement2); + when(connection.getAutoCommit()).thenReturn(true); + + when(resultSet.next()).thenReturn(false); + when(statement2.execute(CREATE_STATEMENT2)).thenThrow(new SQLException(MY_REASON, SQL_STATE, VENDOR_CODE)); + + defaultJDBCAdapter.doCreateTables(transactionContext); + + InOrder inOrder = inOrder(resultSet, connection, statement1, statement2); + inOrder.verify(resultSet).next(); + inOrder.verify(resultSet).close(); + inOrder.verify(connection).createStatement(); + inOrder.verify(statement1).execute(CREATE_STATEMENT1); + inOrder.verify(statement1).close(); + inOrder.verify(connection).createStatement(); + inOrder.verify(statement2).execute(CREATE_STATEMENT2); + inOrder.verify(statement2).close(); + + assertEquals(4, loggingEvents.size()); + assertLog(0, Level.DEBUG, "Executing SQL: " + CREATE_STATEMENT1); + assertLog(1, Level.DEBUG, "Executing SQL: " + CREATE_STATEMENT2); + assertLog(2, Level.WARN, "Could not create JDBC tables; they could already exist. Failure was: " + CREATE_STATEMENT2 + " Message: " + MY_REASON + " SQLState: " + SQL_STATE + " Vendor code: " + VENDOR_CODE); + assertLog(3, Level.WARN, "Failure details: " + MY_REASON); + + } + + private void assertLog(int messageNumber, Level level, String message) { + LogEvent loggingEvent = loggingEvents.get(messageNumber); + assertEquals(level, loggingEvent.getLevel()); + assertEquals(message, loggingEvent.getMessage().getFormattedMessage()); + } + +} \ No newline at end of file diff --git a/activemq-jdbc-store/src/test/java/org/apache/activemq/store/jdbc/adapter/TriesToCreateTablesTest.java b/activemq-jdbc-store/src/test/java/org/apache/activemq/store/jdbc/adapter/TriesToCreateTablesTest.java new file mode 100644 index 0000000000..f3015c949a --- /dev/null +++ b/activemq-jdbc-store/src/test/java/org/apache/activemq/store/jdbc/adapter/TriesToCreateTablesTest.java @@ -0,0 +1,128 @@ +/** + * 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. + */ +package org.apache.activemq.store.jdbc.adapter; + +import org.apache.activemq.store.jdbc.Statements; +import org.apache.activemq.store.jdbc.TransactionContext; +import org.apache.logging.log4j.Level; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.core.LogEvent; +import org.apache.logging.log4j.core.appender.AbstractAppender; +import org.apache.logging.log4j.core.config.Property; +import org.apache.logging.log4j.core.filter.AbstractFilter; +import org.apache.logging.log4j.core.layout.MessageLayout; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InOrder; +import org.mockito.Mock; +import org.mockito.runners.MockitoJUnitRunner; + +import java.io.IOException; +import java.sql.Connection; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.util.ArrayList; +import java.util.List; + +import static org.junit.Assert.assertEquals; +import static org.mockito.Answers.RETURNS_DEEP_STUBS; +import static org.mockito.Mockito.inOrder; +import static org.mockito.Mockito.when; + +@RunWith(MockitoJUnitRunner.class) +public class TriesToCreateTablesTest { + + private static final String CREATE_STATEMENT1 = "createStatement1"; + private static final String CREATE_STATEMENT2 = "createStatement2"; + private static final String[] CREATE_STATEMENTS = new String[] { CREATE_STATEMENT1, CREATE_STATEMENT2 }; + private static final int VENDOR_CODE = 1; + private static final String SQL_STATE = "SqlState"; + private static final String MY_REASON = "MyReason"; + + private DefaultJDBCAdapter defaultJDBCAdapter; + + private List loggingEvents = new ArrayList<>(); + + @Mock + private TransactionContext transactionContext; + + @Mock(answer = RETURNS_DEEP_STUBS) + private Connection connection; + + @Mock + private Statements statements; + + @Mock + private ResultSet resultSet; + + @Mock + private Statement statement1, statement2; + + @Test + public void triesToCreateTheTablesWhenMessageTableExistsAndLogsSqlExceptionsInDebugLevel() throws SQLException, IOException { + final var logger = org.apache.logging.log4j.core.Logger.class.cast(LogManager.getRootLogger()); + final var appender = new AbstractAppender("testAppender", new AbstractFilter() {}, new MessageLayout(), false, new Property[0]) { + @Override + public void append(LogEvent event) { + loggingEvents.add(event.toImmutable()); + } + }; + appender.start(); + + logger.get().addAppender(appender, Level.DEBUG, new AbstractFilter() {}); + logger.addAppender(appender); + + defaultJDBCAdapter = new DefaultJDBCAdapter(); + defaultJDBCAdapter.statements = statements; + + when(statements.getCreateSchemaStatements()).thenReturn(CREATE_STATEMENTS); + when(transactionContext.getConnection()).thenReturn(connection); + when(connection.getMetaData().getTables(null, null, this.statements.getFullMessageTableName(),new String[] { "TABLE" })).thenReturn(resultSet); + when(connection.createStatement()).thenReturn(statement1, statement2); + when(connection.getAutoCommit()).thenReturn(true); + + when(resultSet.next()).thenReturn(true); + when(statement1.execute(CREATE_STATEMENT1)).thenThrow(new SQLException(MY_REASON, SQL_STATE, VENDOR_CODE)); + + defaultJDBCAdapter.doCreateTables(transactionContext); + + InOrder inOrder = inOrder(resultSet, connection, statement1, statement2); + inOrder.verify(resultSet).next(); + inOrder.verify(resultSet).close(); + inOrder.verify(connection).createStatement(); + inOrder.verify(statement1).execute(CREATE_STATEMENT1); + inOrder.verify(statement1).close(); + inOrder.verify(connection).createStatement(); + inOrder.verify(statement2).execute(CREATE_STATEMENT2); + inOrder.verify(statement2).close(); + + assertEquals(3, loggingEvents.size()); + assertLog(0, Level.DEBUG, "Executing SQL: " + CREATE_STATEMENT1); + assertLog(1, Level.DEBUG, "Could not create JDBC tables; The message table already existed. Failure was: " + CREATE_STATEMENT1 + " Message: " + MY_REASON + " SQLState: " + SQL_STATE + " Vendor code: " + VENDOR_CODE); + assertLog(2, Level.DEBUG, "Executing SQL: " + CREATE_STATEMENT2); + + loggingEvents = new ArrayList<>(); + } + + private void assertLog(int messageNumber, Level level, String message) { + LogEvent loggingEvent = loggingEvents.get(messageNumber); + assertEquals(level, loggingEvent.getLevel()); + assertEquals(message, loggingEvent.getMessage().getFormattedMessage()); + } + +} diff --git a/activemq-jdbc-store/src/test/resources/log4j2-test.properties b/activemq-jdbc-store/src/test/resources/log4j2-test.properties new file mode 100644 index 0000000000..df04ea9f1c --- /dev/null +++ b/activemq-jdbc-store/src/test/resources/log4j2-test.properties @@ -0,0 +1,58 @@ +## --------------------------------------------------------------------------- +## 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. +## --------------------------------------------------------------------------- + +# +# The logging properties used during tests +# +rootLogger.level=DEBUG +rootLogger.appenderRef.console.ref=Console +rootLogger.appenderRef.console.filter.threshold.type=ThresholdFilter +rootLogger.appenderRef.console.filter.threshold.level=INFO +rootLogger.appenderRef.logfile.ref=RollingFile + +#logger.scheduler.name=org.apache.activemq.broker.scheduler +#logger.scheduler.level=DEBUG +#logger.network.name=org.apache.activemq.network.DemandForwardingBridgeSupport +#logger.network.level=DEBUG +#logger.failover.name=org.apache.activemq.transport.failover +#logger.failover.level=TRACE +#logger.jdbc.name=org.apache.activemq.store.jdbc +#logger.jdbc.level=TRACE +#logger.cursors.name=org.apache.activemq.broker.region.cursors.AbstractStoreCursor +#logger.cursors.level=DEBUG + +# Appender configuration + +# Console appender +appender.console.type=Console +appender.console.name=Console +appender.console.layout.type=PatternLayout +appender.console.layout.pattern=%d [%-15.15t] - %-5p %-30.30c{1} - %m%n +#appender.console.layout.pattern=%d [%-15.15t] - %-5p %-30.30c{1} - %-10.10X{activemq.broker} %-20.20X{activemq.connector} %-10.10X{activemq.destination} - %m%n + +# RollingFile appender +appender.logfile.type=RollingRandomAccessFile +appender.logfile.name=RollingFile +appender.logfile.fileName=target/activemq-test.log +appender.logfile.filePattern=target/activemq-test.log.%i +appender.logfile.append=true +appender.logfile.layout.type=PatternLayout +appender.logfile.layout.pattern=%d [%-15.15t] - %-5p %-30.30c{1} - %m%n +#appender.logfile.layout.pattern=%d [%-15.15t] - %-5p %-30.30c{1} - %-10.10X{activemq.broker} %-20.20X{activemq.connector} %-10.10X{activemq.destination} - %m%n +appender.logfile.policies.type=Policies +appender.logfile.policies.size.type=SizeBasedTriggeringPolicy +appender.logfile.policies.size.size=1MB diff --git a/activemq-jms-pool/pom.xml b/activemq-jms-pool/pom.xml index 1283cb5f4a..f89c272637 100644 --- a/activemq-jms-pool/pom.xml +++ b/activemq-jms-pool/pom.xml @@ -89,13 +89,13 @@ test - org.slf4j - slf4j-log4j12 + org.apache.logging.log4j + log4j-slf4j-impl test - log4j - log4j + org.apache.logging.log4j + log4j-core test diff --git a/activemq-jms-pool/src/test/java/org/apache/activemq/jms/pool/PooledConnectionFactoryMaximumActiveTest.java b/activemq-jms-pool/src/test/java/org/apache/activemq/jms/pool/PooledConnectionFactoryMaximumActiveTest.java index 071bb6ba8b..3c7095ece4 100644 --- a/activemq-jms-pool/src/test/java/org/apache/activemq/jms/pool/PooledConnectionFactoryMaximumActiveTest.java +++ b/activemq-jms-pool/src/test/java/org/apache/activemq/jms/pool/PooledConnectionFactoryMaximumActiveTest.java @@ -30,7 +30,8 @@ import javax.jms.JMSException; import javax.jms.Session; import org.apache.activemq.ActiveMQConnectionFactory; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.junit.Test; /** @@ -40,7 +41,7 @@ import org.junit.Test; */ public class PooledConnectionFactoryMaximumActiveTest extends JmsPoolTestSupport { - public final static Logger LOG = Logger.getLogger(PooledConnectionFactoryMaximumActiveTest.class); + public final static Logger LOG = LogManager.getLogger(PooledConnectionFactoryMaximumActiveTest.class); public static Connection conn = null; public static int sleepTimeout = 5000; @@ -94,7 +95,7 @@ public class PooledConnectionFactoryMaximumActiveTest extends JmsPoolTestSupport static class TestRunner2 implements Callable { - public final static Logger TASK_LOG = Logger.getLogger(TestRunner2.class); + public final static Logger TASK_LOG = LogManager.getLogger(TestRunner2.class); /** * @return true if test succeeded, false otherwise diff --git a/activemq-jms-pool/src/test/java/org/apache/activemq/jms/pool/PooledConnectionFactoryTest.java b/activemq-jms-pool/src/test/java/org/apache/activemq/jms/pool/PooledConnectionFactoryTest.java index 9e486f4a3b..803e72a445 100644 --- a/activemq-jms-pool/src/test/java/org/apache/activemq/jms/pool/PooledConnectionFactoryTest.java +++ b/activemq-jms-pool/src/test/java/org/apache/activemq/jms/pool/PooledConnectionFactoryTest.java @@ -36,7 +36,8 @@ import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.broker.BrokerService; import org.apache.activemq.command.ConnectionId; import org.apache.activemq.util.Wait; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.junit.Test; import static org.junit.Assert.*; @@ -52,7 +53,7 @@ import static org.junit.Assert.*; */ public class PooledConnectionFactoryTest extends JmsPoolTestSupport { - public final static Logger LOG = Logger.getLogger(PooledConnectionFactoryTest.class); + public final static Logger LOG = LogManager.getLogger(PooledConnectionFactoryTest.class); @Test(timeout = 60000) public void testInstanceOf() throws Exception { @@ -345,7 +346,7 @@ public class PooledConnectionFactoryTest extends JmsPoolTestSupport { static class TestRunner implements Callable { - public final static Logger LOG = Logger.getLogger(TestRunner.class); + public final static Logger LOG = LogManager.getLogger(TestRunner.class); /** * @return true if test succeeded, false otherwise diff --git a/activemq-jms-pool/src/test/java/org/apache/activemq/jms/pool/PooledSessionExhaustionBlockTimeoutTest.java b/activemq-jms-pool/src/test/java/org/apache/activemq/jms/pool/PooledSessionExhaustionBlockTimeoutTest.java index fe0a7ee16f..c5ab15647e 100644 --- a/activemq-jms-pool/src/test/java/org/apache/activemq/jms/pool/PooledSessionExhaustionBlockTimeoutTest.java +++ b/activemq-jms-pool/src/test/java/org/apache/activemq/jms/pool/PooledSessionExhaustionBlockTimeoutTest.java @@ -38,7 +38,8 @@ import javax.jms.TextMessage; import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.broker.BrokerService; import org.apache.activemq.broker.TransportConnector; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.junit.After; import org.junit.Test; @@ -46,7 +47,7 @@ public class PooledSessionExhaustionBlockTimeoutTest extends JmsPoolTestSupport private static final String QUEUE = "FOO"; private static final int NUM_MESSAGES = 500; - private final Logger LOG = Logger.getLogger(getClass()); + private final Logger LOG = LogManager.getLogger(PooledSessionExhaustionBlockTimeoutTest.class); private ActiveMQConnectionFactory factory; private PooledConnectionFactory pooledFactory; diff --git a/activemq-jms-pool/src/test/java/org/apache/activemq/jms/pool/PooledSessionExhaustionTest.java b/activemq-jms-pool/src/test/java/org/apache/activemq/jms/pool/PooledSessionExhaustionTest.java index b92cd396c9..bbfb4caba4 100644 --- a/activemq-jms-pool/src/test/java/org/apache/activemq/jms/pool/PooledSessionExhaustionTest.java +++ b/activemq-jms-pool/src/test/java/org/apache/activemq/jms/pool/PooledSessionExhaustionTest.java @@ -36,7 +36,8 @@ import javax.jms.TextMessage; import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.broker.BrokerService; import org.apache.activemq.broker.TransportConnector; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -46,7 +47,7 @@ public class PooledSessionExhaustionTest extends JmsPoolTestSupport { private static final String QUEUE = "FOO"; private static final int NUM_MESSAGES = 500; - private static final Logger LOG = Logger.getLogger(PooledSessionExhaustionTest.class); + private static final Logger LOG = LogManager.getLogger(PooledSessionExhaustionTest.class); private ActiveMQConnectionFactory factory; private PooledConnectionFactory pooledFactory; diff --git a/activemq-jms-pool/src/test/resources/log4j.properties b/activemq-jms-pool/src/test/resources/log4j.properties deleted file mode 100644 index 2543c16e29..0000000000 --- a/activemq-jms-pool/src/test/resources/log4j.properties +++ /dev/null @@ -1,38 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- - -# -# The logging properties used during tests.. -# -log4j.rootLogger=INFO, out, stdout - -log4j.logger.org.apache.activemq.spring=WARN -#log4j.logger.org.apache.activemq.usecases=DEBUG -#log4j.logger.org.apache.activemq.broker.region=DEBUG -log4j.logger.org.apache.activemq.jms.pool=DEBUG - -# CONSOLE appender not used by default -log4j.appender.stdout=org.apache.log4j.ConsoleAppender -log4j.appender.stdout.layout=org.apache.log4j.PatternLayout -log4j.appender.stdout.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n - -# File appender -log4j.appender.out=org.apache.log4j.FileAppender -log4j.appender.out.layout=org.apache.log4j.PatternLayout -log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n -log4j.appender.out.file=target/activemq-test.log -log4j.appender.out.append=true diff --git a/activemq-jms-pool/src/test/resources/log4j2-test.properties b/activemq-jms-pool/src/test/resources/log4j2-test.properties new file mode 100644 index 0000000000..af4efea81a --- /dev/null +++ b/activemq-jms-pool/src/test/resources/log4j2-test.properties @@ -0,0 +1,54 @@ +## --------------------------------------------------------------------------- +## 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. +## --------------------------------------------------------------------------- + +# +# The logging properties used during tests +# +rootLogger.level=INFO + +rootLogger.appenderRef.console.ref=Console +rootLogger.appenderRef.logfile.ref=RollingFile + +logger.spring.name=org.apache.activemq.spring +logger.spring.level=WARN + +#logger.usecases.name=org.apache.activemq.usecases +#logger.usecases.level=DEBUG + +#logger.region.name=org.apache.activemq.broker.region +#logger.region.level=DEBUG + +logger.pool.name=org.apache.activemq.jms.pool +logger.pool.level=DEBUG + +# Console appender +appender.console.type=Console +appender.console.name=Console +appender.console.layout.type=PatternLayout +appender.console.layout.pattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n + +# RollingFile appender +appender.logfile.type=RollingRandomAccessFile +appender.logfile.name=RollingFile +appender.logfile.fileName=target/activemq-test.log +appender.logfile.filePattern=target/activemq-test.log.%i +appender.logfile.append=true +appender.logfile.layout.type=PatternLayout +appender.logfile.layout.pattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n +appender.logfile.policies.type=Policies +appender.logfile.policies.size.type=SizeBasedTriggeringPolicy +appender.logfile.policies.size.size=1MB diff --git a/activemq-kahadb-store/pom.xml b/activemq-kahadb-store/pom.xml index 4cef43d73d..bb555c9a24 100644 --- a/activemq-kahadb-store/pom.xml +++ b/activemq-kahadb-store/pom.xml @@ -127,13 +127,8 @@ test - org.slf4j - slf4j-log4j12 - test - - - log4j - log4j + org.apache.logging.log4j + log4j-slf4j-impl test diff --git a/activemq-kahadb-store/src/test/java/org/apache/activemq/store/kahadb/JournalCorruptionEofIndexRecoveryTest.java b/activemq-kahadb-store/src/test/java/org/apache/activemq/store/kahadb/JournalCorruptionEofIndexRecoveryTest.java index b41f3c9a5b..0033e0b2c7 100644 --- a/activemq-kahadb-store/src/test/java/org/apache/activemq/store/kahadb/JournalCorruptionEofIndexRecoveryTest.java +++ b/activemq-kahadb-store/src/test/java/org/apache/activemq/store/kahadb/JournalCorruptionEofIndexRecoveryTest.java @@ -50,13 +50,22 @@ import org.apache.activemq.util.ByteSequence; import org.apache.activemq.util.DefaultTestAppender; import org.apache.activemq.util.IOHelper; import org.apache.activemq.util.RecoverableRandomAccessFile; -import org.apache.log4j.Level; -import org.apache.log4j.spi.LoggingEvent; +import org.apache.logging.log4j.Level; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.core.LogEvent; +import org.apache.logging.log4j.core.LoggerContext; +import org.apache.logging.log4j.core.appender.AbstractAppender; +import org.apache.logging.log4j.core.config.AppenderRef; +import org.apache.logging.log4j.core.config.LoggerConfig; +import org.apache.logging.log4j.core.config.Property; +import org.apache.logging.log4j.core.filter.AbstractFilter; +import org.apache.logging.log4j.core.layout.MessageLayout; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.slf4j.event.LoggingEvent; public class JournalCorruptionEofIndexRecoveryTest { @@ -225,23 +234,27 @@ public class JournalCorruptionEofIndexRecoveryTest { } AtomicBoolean trappedExpectedLogMessage = new AtomicBoolean(false); - DefaultTestAppender appender = new DefaultTestAppender() { + + final var logger = org.apache.logging.log4j.core.Logger.class.cast(LogManager.getRootLogger()); + final var appender = new AbstractAppender("testAppender", new AbstractFilter() {}, new MessageLayout(), false, new Property[0]) { @Override - public void doAppend(LoggingEvent event) { + public void append(LogEvent event) { if (event.getLevel() == Level.WARN - && event.getRenderedMessage().contains("Cannot recover message audit") - && event.getThrowableInformation().getThrowable().getLocalizedMessage().contains("Invalid location size")) { + && event.getMessage().getFormattedMessage().contains("Cannot recover message audit") + && event.getThrown().getLocalizedMessage().contains("Invalid location size")) { trappedExpectedLogMessage.set(true); } } }; - org.apache.log4j.Logger.getRootLogger().addAppender(appender); - + appender.start(); + logger.addAppender(appender); + logger.get().addAppender(appender, Level.INFO, new AbstractFilter() {}); try { restartBroker(false); } finally { - org.apache.log4j.Logger.getRootLogger().removeAppender(appender); + logger.removeAppender(appender); + logger.get().removeAppender("testAppender"); } assertEquals("no missing message", 50, broker.getAdminView().getTotalMessageCount()); diff --git a/activemq-kahadb-store/src/test/java/org/apache/activemq/store/kahadb/disk/page/PageFileTest.java b/activemq-kahadb-store/src/test/java/org/apache/activemq/store/kahadb/disk/page/PageFileTest.java index 11b28a8ed2..7eceef1f7e 100644 --- a/activemq-kahadb-store/src/test/java/org/apache/activemq/store/kahadb/disk/page/PageFileTest.java +++ b/activemq-kahadb-store/src/test/java/org/apache/activemq/store/kahadb/disk/page/PageFileTest.java @@ -18,11 +18,14 @@ package org.apache.activemq.store.kahadb.disk.page; import junit.framework.TestCase; import org.apache.activemq.store.kahadb.disk.util.StringMarshaller; -import org.apache.activemq.util.DefaultTestAppender; import org.apache.activemq.util.Wait; -import org.apache.log4j.Appender; -import org.apache.log4j.Level; -import org.apache.log4j.spi.LoggingEvent; +import org.apache.logging.log4j.Level; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.core.LogEvent; +import org.apache.logging.log4j.core.appender.AbstractAppender; +import org.apache.logging.log4j.core.config.Property; +import org.apache.logging.log4j.core.filter.AbstractFilter; +import org.apache.logging.log4j.core.layout.MessageLayout; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -365,19 +368,19 @@ public class PageFileTest extends TestCase { final int numberOfPages = 1000; final AtomicBoolean recoveryEnd = new AtomicBoolean(); - Appender appender = new DefaultTestAppender() { + final var logger = org.apache.logging.log4j.core.Logger.class.cast(LogManager.getLogger(PageFile.class)); + final var appender = new AbstractAppender("testAppender", new AbstractFilter() {}, new MessageLayout(), false, new Property[0]) { @Override - public void doAppend(LoggingEvent event) { - if (event.getLevel().equals(Level.INFO) && event.getMessage().toString().contains("Recovered pageFile free list")) { + public void append(LogEvent event) { + if (event.toImmutable().getLevel().equals(Level.INFO) && event.toImmutable().getMessage().getFormattedMessage().contains("Recovered pageFile free list")) { recoveryEnd.set(true); } } }; + appender.start(); - org.apache.log4j.Logger log4jLogger = - org.apache.log4j.Logger.getLogger(PageFile.class); - log4jLogger.addAppender(appender); - log4jLogger.setLevel(Level.DEBUG); + logger.addAppender(appender); + logger.get().addAppender(appender, Level.DEBUG, new AbstractFilter() {}); PageFile pf = new PageFile(new File("target/test-data"), getName()); pf.delete(); @@ -415,19 +418,18 @@ public class PageFileTest extends TestCase { final int numberOfPages = 100000; final AtomicBoolean recoveryEnd = new AtomicBoolean(); - Appender appender = new DefaultTestAppender() { + final var logger = org.apache.logging.log4j.core.Logger.class.cast(LogManager.getLogger(PageFile.class)); + final var appender = new AbstractAppender("pageAppender", new AbstractFilter() {}, new MessageLayout(), false, new Property[0]) { @Override - public void doAppend(LoggingEvent event) { - if (event.getLevel().equals(Level.INFO) && event.getMessage().toString().contains("Recovered pageFile free list")) { + public void append(LogEvent event) { + if (event.toImmutable().getLevel().equals(Level.INFO) && event.toImmutable().getMessage().getFormattedMessage().contains("Recovered pageFile free list")) { recoveryEnd.set(true); } } }; - - org.apache.log4j.Logger log4jLogger = - org.apache.log4j.Logger.getLogger(PageFile.class); - log4jLogger.addAppender(appender); - log4jLogger.setLevel(Level.DEBUG); + appender.start(); + logger.addAppender(appender); + logger.get().addAppender(appender, Level.DEBUG, new AbstractFilter() {}); PageFile pf = new PageFile(new File("target/test-data"), getName()); pf.delete(); @@ -499,7 +501,7 @@ public class PageFileTest extends TestCase { pf2.flush(); long freePages = pf2.getFreePageCount(); LOG.info("free page count: " + freePages); - return recoveryEnd.get(); + return recoveryEnd.get(); } }, 100000)); diff --git a/activemq-kahadb-store/src/test/resources/log4j.properties b/activemq-kahadb-store/src/test/resources/log4j.properties deleted file mode 100644 index 7cc19418fd..0000000000 --- a/activemq-kahadb-store/src/test/resources/log4j.properties +++ /dev/null @@ -1,42 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- - -# -# The logging properties used during tests.. -# -log4j.rootLogger=INFO, out, stdout - -#log4j.logger.org.apache.activemq.broker.scheduler=DEBUG -#log4j.logger.org.apache.activemq.network.DemandForwardingBridgeSupport=DEBUG -#log4j.logger.org.apache.activemq.transport.failover=TRACE -#log4j.logger.org.apache.activemq.store.jdbc=TRACE -#log4j.logger.org.apache.activemq.broker.region.cursors.AbstractStoreCursor=DEBUG -#log4j.logger.org.apache.activemq.store.jdbc.JDBCMessageStore=DEBUG - -# CONSOLE appender not used by default -log4j.appender.stdout=org.apache.log4j.ConsoleAppender -log4j.appender.stdout.layout=org.apache.log4j.PatternLayout -log4j.appender.stdout.layout.ConversionPattern=%d [%-15.15t] - %-5p %-30.30c{1} - %m%n -#log4j.appender.stdout.layout.ConversionPattern=%d [%-15.15t] - %-5p %-30.30c{1} - %-10.10X{activemq.broker} %-20.20X{activemq.connector} %-10.10X{activemq.destination} - %m%n - -# File appender -log4j.appender.out=org.apache.log4j.FileAppender -log4j.appender.out.layout=org.apache.log4j.PatternLayout -log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] - %-5p %-30.30c{1} - %m%n -#log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] - %-5p %-30.30c{1} - %-10.10X{activemq.broker} %-20.20X{activemq.connector} %-10.10X{activemq.destination} - %m%n -log4j.appender.out.file=target/activemq-test.log -log4j.appender.out.append=true diff --git a/activemq-kahadb-store/src/test/resources/log4j2-test.properties b/activemq-kahadb-store/src/test/resources/log4j2-test.properties new file mode 100644 index 0000000000..16e203809f --- /dev/null +++ b/activemq-kahadb-store/src/test/resources/log4j2-test.properties @@ -0,0 +1,58 @@ +## --------------------------------------------------------------------------- +## 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. +## --------------------------------------------------------------------------- + +# +# The logging properties used during tests +# +rootLogger.level=INFO +rootLogger.appenderRef.console.ref=Console +rootLogger.appenderRef.console.filter.threshold.type=ThresholdFilter +rootLogger.appenderRef.console.filter.threshold.level=INFO +rootLogger.appenderRef.logfile.ref=RollingFile + +#logger.scheduler.name=org.apache.activemq.broker.scheduler +#logger.scheduler.level=DEBUG +#logger.network.name=org.apache.activemq.network.DemandForwardingBridgeSupport +#logger.network.level=DEBUG +#logger.failover.name=org.apache.activemq.transport.failover +#logger.failover.level=TRACE +#logger.jdbc.name=org.apache.activemq.store.jdbc +#logger.jdbc.level=TRACE +#logger.cursors.name=org.apache.activemq.broker.region.cursors.AbstractStoreCursor +#logger.cursors.level=DEBUG + +# Appender configuration + +# Console appender +appender.console.type=Console +appender.console.name=Console +appender.console.layout.type=PatternLayout +appender.console.layout.pattern=%d [%-15.15t] - %-5p %-30.30c{1} - %m%n +#appender.console.layout.pattern=%d [%-15.15t] - %-5p %-30.30c{1} - %-10.10X{activemq.broker} %-20.20X{activemq.connector} %-10.10X{activemq.destination} - %m%n + +# RollingFile appender +appender.logfile.type=RollingRandomAccessFile +appender.logfile.name=RollingFile +appender.logfile.fileName=target/activemq-test.log +appender.logfile.filePattern=target/activemq-test.log.%i +appender.logfile.append=true +appender.logfile.layout.type=PatternLayout +appender.logfile.layout.pattern=%d [%-15.15t] - %-5p %-30.30c{1} - %m%n +#appender.logfile.layout.pattern=%d [%-15.15t] - %-5p %-30.30c{1} - %-10.10X{activemq.broker} %-20.20X{activemq.connector} %-10.10X{activemq.destination} - %m%n +appender.logfile.policies.type=Policies +appender.logfile.policies.size.type=SizeBasedTriggeringPolicy +appender.logfile.policies.size.size=1MB diff --git a/activemq-karaf/pom.xml b/activemq-karaf/pom.xml index 7f21cc4af7..c4d087a9bd 100644 --- a/activemq-karaf/pom.xml +++ b/activemq-karaf/pom.xml @@ -46,18 +46,10 @@ org.ops4j.pax.logging pax-logging-api - 1.11.4 org.ops4j.pax.logging - pax-logging-service - 1.11.4 - - - log4j - apache-log4j-extras - - + pax-logging-log4j2 org.slf4j @@ -65,8 +57,8 @@ test - org.slf4j - slf4j-log4j12 + org.apache.logging.log4j + log4j-slf4j-impl test diff --git a/activemq-log4j-appender/pom.xml b/activemq-log4j-appender/pom.xml index 8c205a789b..054934be0d 100644 --- a/activemq-log4j-appender/pom.xml +++ b/activemq-log4j-appender/pom.xml @@ -36,8 +36,8 @@ activemq-client - log4j - log4j + org.apache.logging.log4j + log4j-core provided @@ -50,8 +50,8 @@ test - org.slf4j - slf4j-log4j12 + org.apache.logging.log4j + log4j-slf4j-impl test @@ -61,8 +61,33 @@ + + + org.apache.maven.plugins + maven-compiler-plugin + 3.1 + + + log4j-plugin-processor + + compile + + process-classes + + only + + org.apache.logging.log4j.core.config.plugins.processor.PluginProcessor + + + + + + 1.8 + 1.8 + + maven-jar-plugin diff --git a/activemq-log4j-appender/src/main/java/org/apache/activemq/util/JmsLogAppenderSupport.java b/activemq-log4j-appender/src/main/java/org/apache/activemq/util/JmsLogAppenderSupport.java index 9cae3b46c7..60ab31ad64 100644 --- a/activemq-log4j-appender/src/main/java/org/apache/activemq/util/JmsLogAppenderSupport.java +++ b/activemq-log4j-appender/src/main/java/org/apache/activemq/util/JmsLogAppenderSupport.java @@ -16,6 +16,11 @@ */ package org.apache.activemq.util; +import org.apache.logging.log4j.core.Filter; +import org.apache.logging.log4j.core.Layout; +import org.apache.logging.log4j.core.LogEvent; +import org.apache.logging.log4j.core.appender.AbstractAppender; + import java.io.Serializable; import java.util.ArrayList; import java.util.Iterator; @@ -28,18 +33,12 @@ import javax.jms.MessageProducer; import javax.jms.Session; import javax.naming.NamingException; -import org.apache.log4j.AppenderSkeleton; -import org.apache.log4j.spi.LoggingEvent; /** * An abstract base class for implementation inheritence for a log4j JMS * appender - * - * */ -public abstract class JmsLogAppenderSupport extends AppenderSkeleton { - - public static final int JMS_PUBLISH_ERROR_CODE = 61616; +public abstract class JmsLogAppenderSupport extends AbstractAppender { private Connection connection; private Session session; @@ -48,6 +47,11 @@ public abstract class JmsLogAppenderSupport extends AppenderSkeleton { private String subjectPrefix = "log4j."; public JmsLogAppenderSupport() { + this("jmslog", (Filter) null); + } + + protected JmsLogAppenderSupport(String name, Filter filter) { + super(name, filter, (Layout) null, true); } public Connection getConnection() throws JMSException, NamingException { @@ -108,7 +112,7 @@ public abstract class JmsLogAppenderSupport extends AppenderSkeleton { } for (Iterator iter = errors.iterator(); iter.hasNext();) { JMSException e = iter.next(); - getErrorHandler().error("Error closing JMS resources: " + e, e, JMS_PUBLISH_ERROR_CODE); + getHandler().error("Error closing JMS resources: " + e, e); } } @@ -121,7 +125,7 @@ public abstract class JmsLogAppenderSupport extends AppenderSkeleton { // lets ensure we're all created getProducer(); } catch (Exception e) { - getErrorHandler().error("Could not create JMS resources: " + e, e, JMS_PUBLISH_ERROR_CODE); + getHandler().error("Could not create JMS resources: " + e, e); } } @@ -139,7 +143,7 @@ public abstract class JmsLogAppenderSupport extends AppenderSkeleton { private static final ThreadLocal APPENDING = new ThreadLocal(); - protected void append(LoggingEvent event) { + public void append(LogEvent event) { if( APPENDING.get()==null ) { APPENDING.set(true); try { @@ -147,14 +151,14 @@ public abstract class JmsLogAppenderSupport extends AppenderSkeleton { Destination destination = getDestination(event); getProducer().send(destination, message); } catch (Exception e) { - getErrorHandler().error("Could not send message due to: " + e, e, JMS_PUBLISH_ERROR_CODE, event); + getHandler().error("Could not send message due to: " + e, event, e); } finally { APPENDING.remove(); } } } - protected Message createMessage(LoggingEvent event) throws JMSException, NamingException { + protected Message createMessage(LogEvent event) throws JMSException, NamingException { Message answer = null; Object value = event.getMessage(); if (allowTextMessages && value instanceof String) { @@ -163,12 +167,12 @@ public abstract class JmsLogAppenderSupport extends AppenderSkeleton { answer = getSession().createObjectMessage((Serializable)value); } answer.setStringProperty("level", event.getLevel().toString()); - answer.setIntProperty("levelInt", event.getLevel().toInt()); + answer.setIntProperty("levelInt", event.getLevel().intLevel()); answer.setStringProperty("threadName", event.getThreadName()); return answer; } - protected Destination getDestination(LoggingEvent event) throws JMSException, NamingException { + protected Destination getDestination(LogEvent event) throws JMSException, NamingException { String name = subjectPrefix + event.getLoggerName(); return getSession().createTopic(name); } diff --git a/activemq-log4j-appender/src/main/java/org/apache/activemq/util/JndiJmsLogAppender.java b/activemq-log4j-appender/src/main/java/org/apache/activemq/util/JndiJmsLogAppender.java index ac92d58be0..a89f9c47b8 100644 --- a/activemq-log4j-appender/src/main/java/org/apache/activemq/util/JndiJmsLogAppender.java +++ b/activemq-log4j-appender/src/main/java/org/apache/activemq/util/JndiJmsLogAppender.java @@ -24,8 +24,6 @@ import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NamingException; -import org.apache.log4j.helpers.LogLog; - /** * A JMS 1.1 log4j appender which uses JNDI to locate a JMS ConnectionFactory to * use for logging events. @@ -117,7 +115,7 @@ public class JndiJmsLogAppender extends JmsLogAppenderSupport { // ------------------------------------------------------------------------- protected Connection createConnection() throws JMSException, NamingException { InitialContext context = createInitialContext(); - LogLog.debug("Looking up ConnectionFactory with jndiName: " + jndiName); + // LogLog.debug("Looking up ConnectionFactory with jndiName: " + jndiName); ConnectionFactory factory = (ConnectionFactory)context.lookup(jndiName); if (factory == null) { throw new JMSException("No such ConnectionFactory for name: " + jndiName); @@ -138,7 +136,7 @@ public class JndiJmsLogAppender extends JmsLogAppenderSupport { if (providerURL != null) { env.put(Context.PROVIDER_URL, providerURL); } else { - LogLog.warn("You have set InitialContextFactoryName option but not the " + "ProviderURL. This is likely to cause problems."); + // LogLog.warn("You have set InitialContextFactoryName option but not the " + "ProviderURL. This is likely to cause problems."); } if (urlPkgPrefixes != null) { env.put(Context.URL_PKG_PREFIXES, urlPkgPrefixes); @@ -149,10 +147,10 @@ public class JndiJmsLogAppender extends JmsLogAppenderSupport { if (securityCredentials != null) { env.put(Context.SECURITY_CREDENTIALS, securityCredentials); } else { - LogLog.warn("You have set SecurityPrincipalName option but not the " + "SecurityCredentials. This is likely to cause problems."); + // LogLog.warn("You have set SecurityPrincipalName option but not the " + "SecurityCredentials. This is likely to cause problems."); } } - LogLog.debug("Looking up JNDI context with environment: " + env); + // LogLog.debug("Looking up JNDI context with environment: " + env); return new InitialContext(env); } } diff --git a/activemq-log4j-appender/src/test/java/org/apache/activemq/util/JmsLogAppenderTest.java b/activemq-log4j-appender/src/test/java/org/apache/activemq/util/JmsLogAppenderTest.java deleted file mode 100644 index 2c5f41e470..0000000000 --- a/activemq-log4j-appender/src/test/java/org/apache/activemq/util/JmsLogAppenderTest.java +++ /dev/null @@ -1,114 +0,0 @@ -/** - * 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. - */ -package org.apache.activemq.util; - -import java.io.IOException; -import java.util.Properties; -import javax.jms.Connection; -import javax.jms.JMSException; -import javax.jms.MessageConsumer; -import javax.jms.Session; -import javax.jms.TextMessage; - -import junit.framework.TestCase; -import org.apache.activemq.ActiveMQConnectionFactory; -import org.apache.activemq.broker.BrokerService; -import org.apache.activemq.command.ActiveMQTopic; -import org.apache.log4j.Level; -import org.apache.log4j.Logger; -import org.apache.log4j.PropertyConfigurator; - -public class JmsLogAppenderTest extends TestCase { - protected BrokerService broker; - - public void testLoggingWithJMS() throws IOException, JMSException { - // Setup the consumers - MessageConsumer info; - MessageConsumer debug; - MessageConsumer warn; - ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("vm://localhost?broker.persistent=false&broker.useJmx=false"); - Connection conn = factory.createConnection(); - conn.start(); - - warn = conn.createSession(false, Session.AUTO_ACKNOWLEDGE).createConsumer(new ActiveMQTopic("log4j.MAIN.WARN")); - info = conn.createSession(false, Session.AUTO_ACKNOWLEDGE).createConsumer(new ActiveMQTopic("log4j.MAIN.INFO")); - debug = conn.createSession(false, Session.AUTO_ACKNOWLEDGE).createConsumer(new ActiveMQTopic("log4j.MAIN.DEBUG")); - - // lets try configure log4j - Properties properties = new Properties(); - properties.load(getClass().getResourceAsStream("test-log4j.properties")); - PropertyConfigurator.configure(properties); - - Logger warnLog; - Logger infoLog; - Logger debugLog; - - warnLog = Logger.getLogger("MAIN.WARN"); - warnLog.setLevel(Level.WARN); - warnLog.warn("Warn Message"); - warnLog.info("Info Message"); - warnLog.debug("Debug Message"); - - infoLog = Logger.getLogger("MAIN.INFO"); - infoLog.setLevel(Level.INFO); - infoLog.warn("Warn Message"); - infoLog.info("Info Message"); - infoLog.debug("Debug Message"); - - debugLog = Logger.getLogger("MAIN.DEBUG"); - debugLog.setLevel(Level.DEBUG); - debugLog.warn("Warn Message"); - debugLog.info("Info Message"); - debugLog.debug("Debug Message"); - - TextMessage msg; - - // Test warn level - msg = (TextMessage)warn.receive(1000); - assertNotNull(msg); - assertEquals("Warn Message", msg.getText()); - - msg = (TextMessage)warn.receive(1000); - assertNull(msg); // We should not receive anymore message because our - // level is warning only - - // Test info level - msg = (TextMessage)info.receive(1000); - assertNotNull(msg); - assertEquals("Warn Message", msg.getText()); - - msg = (TextMessage)info.receive(1000); - assertNotNull(msg); - assertEquals("Info Message", msg.getText()); - - msg = (TextMessage)info.receive(1000); - assertNull(msg); // We should not receive the debug message - - // Test debug level - msg = (TextMessage)debug.receive(1000); - assertNotNull(msg); - assertEquals("Warn Message", msg.getText()); - - msg = (TextMessage)debug.receive(1000); - assertNotNull(msg); - assertEquals("Info Message", msg.getText()); - - msg = (TextMessage)debug.receive(1000); - assertNotNull(msg); - } - -} diff --git a/activemq-mqtt/pom.xml b/activemq-mqtt/pom.xml index d14cf554cd..7ffe4b5a8f 100644 --- a/activemq-mqtt/pom.xml +++ b/activemq-mqtt/pom.xml @@ -153,13 +153,13 @@ test - org.slf4j - slf4j-log4j12 + org.apache.logging.log4j + log4j-slf4j-impl test - log4j - log4j + org.apache.logging.log4j + log4j-core test diff --git a/activemq-mqtt/src/test/resources/log4j.properties b/activemq-mqtt/src/test/resources/log4j.properties deleted file mode 100644 index 18af1aff92..0000000000 --- a/activemq-mqtt/src/test/resources/log4j.properties +++ /dev/null @@ -1,36 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- - -# -# The logging properties used during tests.. -# -log4j.rootLogger=INFO, out, stdout - -log4j.logger.org.apache.activemq.transport.mqtt=INFO - -# CONSOLE appender not used by default -log4j.appender.stdout=org.apache.log4j.ConsoleAppender -log4j.appender.stdout.layout=org.apache.log4j.PatternLayout -log4j.appender.stdout.layout.ConversionPattern=%d | %-5p | %-30.30c{1} | %m%n - -# File appender -log4j.appender.out=org.apache.log4j.FileAppender -log4j.appender.out.layout=org.apache.log4j.PatternLayout -log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] - %-5p %-30.30c{1} - %m%n -#log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] - %-5p %-30.30c{1} - %-10.10X{activemq.broker} %-20.20X{activemq.connector} %-10.10X{activemq.destination} - %m%n -log4j.appender.out.file=target/activemq-test.log -log4j.appender.out.append=true diff --git a/activemq-mqtt/src/test/resources/log4j2-test.properties b/activemq-mqtt/src/test/resources/log4j2-test.properties new file mode 100644 index 0000000000..dd40652139 --- /dev/null +++ b/activemq-mqtt/src/test/resources/log4j2-test.properties @@ -0,0 +1,46 @@ +## --------------------------------------------------------------------------- +## 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. +## --------------------------------------------------------------------------- + +# +# The logging properties used during tests +# +rootLogger=INFO + +rootLogger.appenderRef.console.ref=Console +rootLogger.appenderRef.logfile.ref=RollingFile + +logger.mqtt.name=org.apache.activemq.transport.mqtt +logger.mqtt.level=INFO + +# Console appender +appender.console.type=Console +appender.console.name=Console +appender.console.layout.type=PatternLayout +appender.console.layout.pattern=%d | %-5p | %-30.30c{1} | %m%n + +# RollingFile appender +appender.logfile.type=RollingRandomAccessFile +appender.logfile.name=RollingFile +appender.logfile.fileName=target/activemq-test.log +appender.logfile.filePattern=target/activemq-test.log.%i +appender.logfile.append=true +appender.logfile.layout.type=PatternLayout +appender.logfile.layout.pattern=%d [%-15.15t] - %-5p %-30.30c{1} - %m%n +#appender.logfile.layout.pattern=%d [%-15.15t] - %-5p %-30.30c{1} - %-10.10X{activemq.broker} %-20.20X{activemq.connector} %-10.10X{activemq.destination} - %m%n +appender.logfile.policies.type=Policies +appender.logfile.policies.size.type=SizeBasedTriggeringPolicy +appender.logfile.policies.size.size=1MB diff --git a/activemq-partition/pom.xml b/activemq-partition/pom.xml index 2255b1301b..aa6d2d6f67 100644 --- a/activemq-partition/pom.xml +++ b/activemq-partition/pom.xml @@ -48,29 +48,18 @@ org.linkedin org.linkedin.zookeeper-impl - ${linkedin-zookeeper-version} - - - org.json - json - - + + + org.apache.logging.log4j + log4j-slf4j-impl org.linkedin org.linkedin.util-core - ${linkedin-zookeeper-version} org.apache.zookeeper zookeeper - ${zookeeper-version} - - - io.netty - netty - - @@ -88,16 +77,6 @@ - - org.slf4j - slf4j-log4j12 - test - - - log4j - log4j - test - org.apache.activemq activemq-broker diff --git a/activemq-pool/pom.xml b/activemq-pool/pom.xml index a7c3a1e218..c63d6fbe91 100644 --- a/activemq-pool/pom.xml +++ b/activemq-pool/pom.xml @@ -82,13 +82,13 @@ test - org.slf4j - slf4j-log4j12 + org.apache.logging.log4j + log4j-slf4j-impl test - log4j - log4j + org.apache.logging.log4j + log4j-core test diff --git a/activemq-ra/pom.xml b/activemq-ra/pom.xml index 791feed39e..10d929d754 100644 --- a/activemq-ra/pom.xml +++ b/activemq-ra/pom.xml @@ -75,8 +75,8 @@ test - org.slf4j - slf4j-log4j12 + org.apache.logging.log4j + log4j-slf4j-impl test diff --git a/activemq-ra/src/test/java/org/apache/activemq/ra/MDBTest.java b/activemq-ra/src/test/java/org/apache/activemq/ra/MDBTest.java index 7a44345ade..a01079ce3a 100644 --- a/activemq-ra/src/test/java/org/apache/activemq/ra/MDBTest.java +++ b/activemq-ra/src/test/java/org/apache/activemq/ra/MDBTest.java @@ -67,13 +67,13 @@ import org.apache.activemq.command.ActiveMQMessage; import org.apache.activemq.command.ActiveMQQueue; import org.apache.activemq.command.ConsumerInfo; import org.apache.activemq.util.Wait; -import org.apache.log4j.Appender; -import org.apache.log4j.Layout; -import org.apache.log4j.Level; -import org.apache.log4j.LogManager; -import org.apache.log4j.spi.ErrorHandler; -import org.apache.log4j.spi.Filter; -import org.apache.log4j.spi.LoggingEvent; +import org.apache.logging.log4j.Level; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.core.LogEvent; +import org.apache.logging.log4j.core.appender.AbstractAppender; +import org.apache.logging.log4j.core.config.Property; +import org.apache.logging.log4j.core.filter.AbstractFilter; +import org.apache.logging.log4j.core.layout.MessageLayout; import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -478,67 +478,20 @@ public class MDBTest { brokerService.start(); final AtomicReference errorMessage = new AtomicReference(); - final Appender testAppender = new Appender() { - + final var appender = new AbstractAppender("test", new AbstractFilter() {}, new MessageLayout(), false, new Property[0]) { @Override - public void addFilter(Filter filter) { - } - - @Override - public Filter getFilter() { - return null; - } - - @Override - public void clearFilters() { - } - - @Override - public void close() { - } - - @Override - public void doAppend(LoggingEvent event) { - if (event.getLevel().isGreaterOrEqual(Level.ERROR)) { - System.err.println("Event :" + event.getRenderedMessage()); - errorMessage.set(event.getRenderedMessage()); + public void append(LogEvent event) { + if (event.getLevel().isMoreSpecificThan(Level.ERROR)) { + System.err.println("Event :" + event.getMessage().getFormattedMessage()); + errorMessage.set(event.getMessage().getFormattedMessage()); } } - - @Override - public String getName() { - return null; - } - - @Override - public void setErrorHandler(ErrorHandler errorHandler) { - } - - @Override - public ErrorHandler getErrorHandler() { - return null; - } - - @Override - public void setLayout(Layout layout) { - } - - @Override - public Layout getLayout() { - return null; - } - - @Override - public void setName(String s) { - } - - @Override - public boolean requiresLayout() { - return false; - } }; + appender.start(); - LogManager.getRootLogger().addAppender(testAppender); + final var logger = org.apache.logging.log4j.core.Logger.class.cast(LogManager.getRootLogger()); + logger.addAppender(appender); + logger.get().addAppender(appender, Level.INFO, new AbstractFilter() {}); ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(brokerUrl); Connection connection = factory.createConnection(); @@ -606,7 +559,9 @@ public class MDBTest { assertNotNull("We got an error message", errorMessage.get()); assertTrue("correct message: " + errorMessage.get(), errorMessage.get().contains("zero")); - LogManager.getRootLogger().removeAppender(testAppender); + logger.removeAppender(appender); + logger.get().removeAppender("test"); + brokerService.stop(); } diff --git a/activemq-ra/src/test/resources/log4j.properties b/activemq-ra/src/test/resources/log4j.properties deleted file mode 100644 index 4d44fd56ae..0000000000 --- a/activemq-ra/src/test/resources/log4j.properties +++ /dev/null @@ -1,36 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- - -# -# The logging properties used during tests.. -# -log4j.rootLogger=INFO, out, stdout - -log4j.logger.org.apache.activemq.spring=WARN -#log4j.logger.org.apache.activemq.ra=DEBUG - -# CONSOLE appender not used by default -log4j.appender.stdout=org.apache.log4j.ConsoleAppender -log4j.appender.stdout.layout=org.apache.log4j.PatternLayout -log4j.appender.stdout.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n - -# File appender -log4j.appender.out=org.apache.log4j.FileAppender -log4j.appender.out.layout=org.apache.log4j.PatternLayout -log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n -log4j.appender.out.file=target/activemq-test.log -log4j.appender.out.append=true diff --git a/activemq-ra/src/test/resources/log4j2-test.properties b/activemq-ra/src/test/resources/log4j2-test.properties new file mode 100644 index 0000000000..3dcf186bcc --- /dev/null +++ b/activemq-ra/src/test/resources/log4j2-test.properties @@ -0,0 +1,48 @@ +## --------------------------------------------------------------------------- +## 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. +## --------------------------------------------------------------------------- + +# +# The logging properties used during tests +# +rootLogger.level=INFO + +rootLogger.appenderRef.console.ref=Console +rootLogger.appenderRef.console.filter.threshold.type=ThresholdFilter +rootLogger.appenderRef.console.filter.threshold.level=INFO +rootLogger.appenderRef.logfile.ref=RollingFile + +# Appender configuration + +# Console appender +appender.console.type=Console +appender.console.name=Console +appender.console.layout.type=PatternLayout +appender.console.layout.pattern=%d [%-15.15t] - %-5p %-30.30c{1} - %m%n +#appender.console.layout.pattern=%d [%-15.15t] - %-5p %-30.30c{1} - %-10.10X{activemq.broker} %-20.20X{activemq.connector} %-10.10X{activemq.destination} - %m%n + +# RollingFile appender +appender.logfile.type=RollingRandomAccessFile +appender.logfile.name=RollingFile +appender.logfile.fileName=target/activemq-test.log +appender.logfile.filePattern=target/activemq-test.log.%i +appender.logfile.append=true +appender.logfile.layout.type=PatternLayout +appender.logfile.layout.pattern=%d [%-15.15t] - %-5p %-30.30c{1} - %m%n +#appender.logfile.layout.pattern=%d [%-15.15t] - %-5p %-30.30c{1} - %-10.10X{activemq.broker} %-20.20X{activemq.connector} %-10.10X{activemq.destination} - %m%n +appender.logfile.policies.type=Policies +appender.logfile.policies.size.type=SizeBasedTriggeringPolicy +appender.logfile.policies.size.size=1MB diff --git a/activemq-rar/pom.xml b/activemq-rar/pom.xml index 98bc70ed8f..1c387873d5 100644 --- a/activemq-rar/pom.xml +++ b/activemq-rar/pom.xml @@ -340,12 +340,12 @@ activemq-mqtt - log4j - log4j + org.apache.logging.log4j + log4j-core - org.slf4j - slf4j-log4j12 + org.apache.logging.log4j + log4j-slf4j-impl runtime diff --git a/activemq-rar/src/main/rar/log4j.properties b/activemq-rar/src/main/rar/log4j.properties deleted file mode 100644 index e28a354deb..0000000000 --- a/activemq-rar/src/main/rar/log4j.properties +++ /dev/null @@ -1,35 +0,0 @@ -## --------------------------------------------------------------------------- -## 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.rootLogger=INFO, stdout - -log4j.logger.org.apache.activemq.spring=WARN -log4j.logger.org.springframework=WARN -log4j.logger.org.apache.xbean.spring=WARN - - -# CONSOLE appender not used by default -log4j.appender.stdout=org.apache.log4j.ConsoleAppender -log4j.appender.stdout.layout=org.apache.log4j.PatternLayout -log4j.appender.stdout.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n - -# File appender -log4j.appender.out=org.apache.log4j.FileAppender -log4j.appender.out.layout=org.apache.log4j.PatternLayout -log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n -log4j.appender.out.file=activemq-ra.log -log4j.appender.out.append=true diff --git a/activemq-log4j-appender/src/test/resources/org/apache/activemq/util/test-log4j.properties b/activemq-rar/src/main/rar/log4j2.properties similarity index 66% rename from activemq-log4j-appender/src/test/resources/org/apache/activemq/util/test-log4j.properties rename to activemq-rar/src/main/rar/log4j2.properties index 53c0490b90..587e97ffad 100644 --- a/activemq-log4j-appender/src/test/resources/org/apache/activemq/util/test-log4j.properties +++ b/activemq-rar/src/main/rar/log4j2.properties @@ -15,8 +15,21 @@ ## limitations under the License. ## --------------------------------------------------------------------------- -# Make level to fatal so it would not affect the test case -log4j.rootLogger=fatal, jms +rootLogger.level=INFO -log4j.appender.jms=org.apache.activemq.util.JndiJmsLogAppender -log4j.appender.jms.jndiName=ConnectionFactory +rootLogger.appenderRef.console.ref=Console + +logger.spring.name=org.apache.activemq.spring +logger.spring.level=WARN + +logger.springframework.name=org.springframework +logger.springframework.level=WARN + +logger.xbean.name=org.apache.xbean.spring +logger.xbean.level=WARN + +# Console appender +appender.console.type=Console +appender.console.name=Console +appender.console.layout.type=PatternLayout +appender.console.layout.pattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n diff --git a/activemq-runtime-config/pom.xml b/activemq-runtime-config/pom.xml index a0784ab37e..a0fbdd85bf 100644 --- a/activemq-runtime-config/pom.xml +++ b/activemq-runtime-config/pom.xml @@ -82,13 +82,13 @@ test - org.slf4j - slf4j-log4j12 + org.apache.logging.log4j + log4j-slf4j-impl test - log4j - log4j + org.apache.logging.log4j + log4j-core test diff --git a/activemq-runtime-config/src/test/resources/log4j.properties b/activemq-runtime-config/src/test/resources/log4j.properties deleted file mode 100644 index a1905e32ad..0000000000 --- a/activemq-runtime-config/src/test/resources/log4j.properties +++ /dev/null @@ -1,36 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- - -# -# The logging properties used during tests.. -# -log4j.rootLogger=INFO, out, stdout - -#log4j.logger.org.apache.activemq=DEBUG -log4j.logger.org.apache.activemq.plugin.RuntimeConfigurationBroker=TRACE - -# CONSOLE appender not used by default -log4j.appender.stdout=org.apache.log4j.ConsoleAppender -log4j.appender.stdout.layout=org.apache.log4j.PatternLayout -log4j.appender.stdout.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n - -# File appender -log4j.appender.out=org.apache.log4j.FileAppender -log4j.appender.out.layout=org.apache.log4j.PatternLayout -log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n -log4j.appender.out.file=target/activemq-test.log -log4j.appender.out.append=true diff --git a/activemq-runtime-config/src/test/resources/log4j2-test.properties b/activemq-runtime-config/src/test/resources/log4j2-test.properties new file mode 100644 index 0000000000..eb27305c96 --- /dev/null +++ b/activemq-runtime-config/src/test/resources/log4j2-test.properties @@ -0,0 +1,48 @@ +## --------------------------------------------------------------------------- +## 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. +## --------------------------------------------------------------------------- + +# +# The logging properties used during tests +# +rootLogger.level=INFO + +rootLogger.appenderRef.console.ref=Console +rootLogger.appenderRef.logfile.ref=RollingFile + +#logger.activemq.name=org.apache.activemq +#logger.activemq.level=DEBUG + +logger.runtime.name=org.apache.activemq.plugin.RuntimeConfigurationBroker +logger.runtime.level=TRACE + +# Console appender +appender.console.type=Console +appender.console.name=Console +appender.console.layout.type=PatternLayout +appender.console.layout.pattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n + +# RollingFile appender +appender.logfile.type=RollingRandomAccessFile +appender.logfile.name=RollingFile +appender.logfile.fileName=target/activemq-test.log +appender.logfile.filePattern=target/activemq-test.log.%i +appender.logfile.append=true +appender.logfile.layout.type=PatternLayout +appender.logfile.layout.pattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n +appender.logfile.policies.type=Policies +appender.logfile.policies.size.type=SizeBasedTriggeringPolicy +appender.logfile.policies.size.size=1MB diff --git a/activemq-shiro/pom.xml b/activemq-shiro/pom.xml index 8d6ca0df58..84c5811b71 100644 --- a/activemq-shiro/pom.xml +++ b/activemq-shiro/pom.xml @@ -83,12 +83,6 @@ test-jar test - - commons-logging - commons-logging - ${commons-logging-version} - test - diff --git a/activemq-web-console/src/main/resources/log4j.properties b/activemq-web-console/src/main/resources/log4j.properties deleted file mode 100644 index a4f59aa2b2..0000000000 --- a/activemq-web-console/src/main/resources/log4j.properties +++ /dev/null @@ -1,38 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- - -# -# The logging properties used during tests.. -# -log4j.rootLogger=INFO, stdout - -log4j.logger.org.apache.activemq=INFO -log4j.logger.org.apache.activemq.spring=WARN -log4j.logger.org.springframework=warn - - -# CONSOLE appender not used by default -log4j.appender.stdout=org.apache.log4j.ConsoleAppender -log4j.appender.stdout.layout=org.apache.log4j.PatternLayout -log4j.appender.stdout.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n - -# File appender -log4j.appender.out=org.apache.log4j.FileAppender -log4j.appender.out.layout=org.apache.log4j.PatternLayout -log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n -log4j.appender.out.file=activemq-console.log -log4j.appender.out.append=true diff --git a/activemq-web-console/src/main/resources/log4j2.properties b/activemq-web-console/src/main/resources/log4j2.properties new file mode 100644 index 0000000000..5c85797fee --- /dev/null +++ b/activemq-web-console/src/main/resources/log4j2.properties @@ -0,0 +1,38 @@ +## --------------------------------------------------------------------------- +## 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. +## --------------------------------------------------------------------------- + +# +# The logging properties used during tests +# +rootLogger.level=INFO + +rootLogger.appenderRef.console.ref=Console + +logger.activemq.name=org.apache.activemq +logger.activemq.level=INFO + +logger.spring.name=org.apache.activemq.spring +logger.spring.level=WARN + +logger.springframework.name=org.springframework +logger.springframework.level=WARN + +# Console appender +appender.console.type=Console +appender.console.name=Console +appender.console.layout.type=PatternLayout +appender.console.layout.pattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n diff --git a/activemq-web-demo/pom.xml b/activemq-web-demo/pom.xml index d4e7847307..9263f1153a 100644 --- a/activemq-web-demo/pom.xml +++ b/activemq-web-demo/pom.xml @@ -126,8 +126,8 @@ org.apache.xbean*;version="[3.13,5)", org.slf4j;version="[1.6,2)";resolution:=optional, org.slf4j.spi;version="[1.6,2)";resolution:=optional, - org.apache.log4j;version="[1.2.14,2)";resolution:=optional, - org.apache.log4j.spi;version="[1.2.14,2)";resolution:=optional + org.apache.log4j;version="[2,3)";resolution:=optional, + org.apache.log4j.spi;version="[2,3)";resolution:=optional !* @@ -178,6 +178,12 @@ ${project.groupId} activeio-core + + + javax.servlet + servlet-api + + org.apache.activemq @@ -185,8 +191,8 @@ true - org.slf4j - slf4j-log4j12 + org.apache.logging.log4j + log4j-slf4j-impl test diff --git a/activemq-web-demo/src/main/resources/log4j.properties b/activemq-web-demo/src/main/resources/log4j.properties deleted file mode 100644 index df9480b4b3..0000000000 --- a/activemq-web-demo/src/main/resources/log4j.properties +++ /dev/null @@ -1,36 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- - -# -# The logging properties used during tests.. -# -log4j.rootLogger=INFO, out, stdout - -log4j.logger.org.apache.activemq.spring=WARN -log4j.logger.org.apache.activemq.web=DEBUG - -# CONSOLE appender not used by default -log4j.appender.stdout=org.apache.log4j.ConsoleAppender -log4j.appender.stdout.layout=org.apache.log4j.PatternLayout -log4j.appender.stdout.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n - -# File appender -log4j.appender.out=org.apache.log4j.FileAppender -log4j.appender.out.layout=org.apache.log4j.PatternLayout -log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n -log4j.appender.out.file=target/test-reports/activemq-test.log -log4j.appender.out.append=true diff --git a/activemq-web-demo/src/main/resources/log4j2.properties b/activemq-web-demo/src/main/resources/log4j2.properties new file mode 100644 index 0000000000..3e699f1282 --- /dev/null +++ b/activemq-web-demo/src/main/resources/log4j2.properties @@ -0,0 +1,48 @@ +## --------------------------------------------------------------------------- +## 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. +## --------------------------------------------------------------------------- + +# +# The logging properties used during tests +# +rootLogger.level=INFO + +rootLogger.appenderRef.console.ref=Console +rootLogger.appenderRef.logfile.ref=RollingFile + +logger.spring.name=org.apache.activemq.spring +logger.spring.level=WARN + +logger.web.name=org.apache.activemq.web +logger.web.level=DEBUG + +# Console appender +appender.console.type=Console +appender.console.name=Console +appender.console.layout.type=PatternLayout +appender.console.layout.pattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n + +# RollingFile appender +appender.logfile.type=RollingRandomAccessFile +appender.logfile.name=RollingFile +appender.logfile.fileName=target/test-reports/activemq-test.log +appender.logfile.filePattern=target/test-reports/activemq-test.log.%i +appender.logfile.append=true +appender.logfile.layout.type=PatternLayout +appender.logfile.layout.pattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n +appender.logfile.policies.type=Policies +appender.logfile.policies.size.type=SizeBasedTriggeringPolicy +appender.logfile.policies.size.size=1MB diff --git a/activemq-web-demo/src/test/resources/log4j.properties b/activemq-web-demo/src/test/resources/log4j.properties deleted file mode 100644 index df9480b4b3..0000000000 --- a/activemq-web-demo/src/test/resources/log4j.properties +++ /dev/null @@ -1,36 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- - -# -# The logging properties used during tests.. -# -log4j.rootLogger=INFO, out, stdout - -log4j.logger.org.apache.activemq.spring=WARN -log4j.logger.org.apache.activemq.web=DEBUG - -# CONSOLE appender not used by default -log4j.appender.stdout=org.apache.log4j.ConsoleAppender -log4j.appender.stdout.layout=org.apache.log4j.PatternLayout -log4j.appender.stdout.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n - -# File appender -log4j.appender.out=org.apache.log4j.FileAppender -log4j.appender.out.layout=org.apache.log4j.PatternLayout -log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n -log4j.appender.out.file=target/test-reports/activemq-test.log -log4j.appender.out.append=true diff --git a/activemq-web-demo/src/test/resources/log4j2-test.properties b/activemq-web-demo/src/test/resources/log4j2-test.properties new file mode 100644 index 0000000000..ca3d112e88 --- /dev/null +++ b/activemq-web-demo/src/test/resources/log4j2-test.properties @@ -0,0 +1,48 @@ +## --------------------------------------------------------------------------- +## 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. +## --------------------------------------------------------------------------- + +# +# The logging properties used during tests +# +rootLogger.level=INFO + +rootLogger.appenderRef.console.ref=Console +rootLogger.appenderRef.logfile.ref=RollingFile + +logger.spring.name=org.apache.activemq.spring +logger.spring.level=WARN + +logger.web.name=org.apache.activemq.web +logger.web.level=DEBUG + +# Console appender +appender.console.type=Console +appender.console.name=Console +appender.console.layout.type=PatternLayout +appender.console.layout.pattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n + +# RollingFile appender +appender.logfile.type=RollingRandomAccessFile +appender.logfile.name=RollingFile +appender.logfile.fileName=target/test-reports/activemq-test.log +appender.logfile.filePattern=target/test-reports/activemq-test.log.%i +appender.logfile.append=true +appender.logfile.layout.type=PatternLayout +appender.logfile.layout.pattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n +appender.logfile.policies.type=Policies +appender.logfile.policies.size.type=SizeBasedTriggeringPolicy +appender.logfile.policies.size.size=1MB \ No newline at end of file diff --git a/activemq-web/pom.xml b/activemq-web/pom.xml index 01cacabc19..454f283846 100644 --- a/activemq-web/pom.xml +++ b/activemq-web/pom.xml @@ -58,6 +58,10 @@ commons-io commons-io + + javax.xml.bind + jaxb-api + ${project.groupId} activemq-unit-tests @@ -129,8 +133,8 @@ test - org.slf4j - slf4j-log4j12 + org.apache.logging.log4j + log4j-slf4j-impl test diff --git a/assembly/pom.xml b/assembly/pom.xml index d7000154e3..e4a0810d49 100644 --- a/assembly/pom.xml +++ b/assembly/pom.xml @@ -75,13 +75,6 @@ org.linkedin org.linkedin.zookeeper-impl - ${linkedin-zookeeper-version} - - - org.json - json - - org.linkedin @@ -91,13 +84,6 @@ org.apache.zookeeper zookeeper - ${zookeeper-version} - - - io.netty - netty - - @@ -250,8 +236,12 @@ xpp3 - log4j - log4j + org.apache.logging.log4j + log4j-core + + + org.apache.logging.log4j + log4j-api jakarta.jms @@ -361,26 +351,25 @@ - org.slf4j slf4j-api + + org.apache.logging.log4j + log4j-slf4j-impl + org.slf4j - slf4j-log4j12 + jcl-over-slf4j - org.slf4j - jcl-over-slf4j + org.apache.geronimo.specs + geronimo-annotation_1.0_spec - org.apache.geronimo.specs - geronimo-annotation_1.0_spec - - - org.ow2.asm - asm + org.ow2.asm + asm @@ -432,16 +421,6 @@ json-simple ${json-simple-version} - - io.fabric8.insight - insight-log-core - ${insight-version} - - - io.fabric8.insight - insight-log4j - ${insight-version} - org.ops4j.pax.url pax-url-aether diff --git a/assembly/src/main/descriptors/common-bin.xml b/assembly/src/main/descriptors/common-bin.xml index 03409c37fa..2d259b9835 100644 --- a/assembly/src/main/descriptors/common-bin.xml +++ b/assembly/src/main/descriptors/common-bin.xml @@ -193,8 +193,9 @@ org.apache.commons:commons-pool2 commons-codec:commons-codec org.apache.commons:commons-lang3 - org.slf4j:slf4j-log4j12 - log4j:log4j + org.apache.logging.log4j:log4j-slf4j-impl + org.apache.logging.log4j:log4j-api + org.apache.logging.log4j:log4j-core org.apache.geronimo.specs:geronimo-j2ee-connector_1.5_spec org.apache.httpcomponents:httpclient org.apache.httpcomponents:httpcore @@ -222,11 +223,6 @@ org.apache.shiro:shiro-core org.apache.shiro:shiro-spring - - - io.fabric8.insight:insight-log-core - io.fabric8.insight:insight-log4j - 0644 0755 diff --git a/assembly/src/release/conf/activemq.xml b/assembly/src/release/conf/activemq.xml index 6c56f38bdb..9f32bd90f5 100644 --- a/assembly/src/release/conf/activemq.xml +++ b/assembly/src/release/conf/activemq.xml @@ -28,12 +28,6 @@ - - - - diff --git a/assembly/src/release/conf/log4j.properties b/assembly/src/release/conf/log4j.properties deleted file mode 100644 index c4c43af268..0000000000 --- a/assembly/src/release/conf/log4j.properties +++ /dev/null @@ -1,89 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- - -# -# This file controls most of the logging in ActiveMQ which is mainly based around -# the commons logging API. -# -log4j.rootLogger=INFO, console, logfile -log4j.logger.org.apache.activemq.spring=WARN -log4j.logger.org.apache.activemq.web.handler=WARN -log4j.logger.org.springframework=WARN -log4j.logger.org.apache.xbean=WARN -log4j.logger.org.apache.camel=INFO -log4j.logger.org.eclipse.jetty=WARN - -# When debugging or reporting problems to the ActiveMQ team, -# comment out the above lines and uncomment the next. - -#log4j.rootLogger=DEBUG, logfile, console - -# Or for more fine grained debug logging uncomment one of these -#log4j.logger.org.apache.activemq=DEBUG -#log4j.logger.org.apache.camel=DEBUG - -# Console appender -log4j.appender.console=org.apache.log4j.ConsoleAppender -log4j.appender.console.layout=org.apache.log4j.PatternLayout -log4j.appender.console.layout.ConversionPattern=%5p | %m%n -log4j.appender.console.threshold=INFO - -# File appender -log4j.appender.logfile=org.apache.log4j.RollingFileAppender -log4j.appender.logfile.file=${activemq.data}/activemq.log -log4j.appender.logfile.maxFileSize=1024KB -log4j.appender.logfile.maxBackupIndex=5 -log4j.appender.logfile.append=true -log4j.appender.logfile.layout=org.apache.log4j.EnhancedPatternLayout -log4j.appender.logfile.layout.ConversionPattern=%d | %-5p | %m | %c | %t%n%throwable{full} - -# you can control the rendering of exception in the ConversionPattern -# by default, we display the full stack trace -# if you want to display short form of the exception, you can use -# -# log4j.appender.logfile.layout.ConversionPattern=%d | %-5p | %m | %c | %t%n%throwable{short} -# -# a classic issue with filebeat/logstash is about multiline exception. The following pattern -# allows to work smoothly with filebeat/logstash -# -# log4j.appender.logfile.layour.ConversionPattern=%d | %-5p | %m | %c | %t%n%replace(%throwable){\n}{ } -# - -# use some of the following patterns to see MDC logging data -# -# %X{activemq.broker} -# %X{activemq.connector} -# %X{activemq.destination} -# -# e.g. -# -# log4j.appender.logfile.layout.ConversionPattern=%d | %-20.20X{activemq.connector} | %-5p | %m | %c | %t%n - -########### -# Audit log -########### - -log4j.additivity.org.apache.activemq.audit=false -log4j.logger.org.apache.activemq.audit=INFO, audit - -log4j.appender.audit=org.apache.log4j.RollingFileAppender -log4j.appender.audit.file=${activemq.data}/audit.log -log4j.appender.audit.maxFileSize=1024KB -log4j.appender.audit.maxBackupIndex=5 -log4j.appender.audit.append=true -log4j.appender.audit.layout=org.apache.log4j.PatternLayout -log4j.appender.audit.layout.ConversionPattern=%-5p | %m | %t%n diff --git a/assembly/src/release/conf/log4j2.properties b/assembly/src/release/conf/log4j2.properties new file mode 100644 index 0000000000..ec6c1945d2 --- /dev/null +++ b/assembly/src/release/conf/log4j2.properties @@ -0,0 +1,113 @@ +## --------------------------------------------------------------------------- +## 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. +## --------------------------------------------------------------------------- + +# +# When debugging or reporting problems to the ActiveMQ team, +# change rootLogger level to DEBUG +# +rootLogger.level=INFO +rootLogger.appenderRef.console.ref=Console +rootLogger.appenderRef.console.filter.threshold.type=ThresholdFilter +rootLogger.appenderRef.console.filter.threshold.level=INFO +rootLogger.appenderRef.logfile.ref=RollingFile + +# Loggers configuration + +# ActiveMQ Spring +logger.spring.name=org.apache.activemq.spring +logger.spring.level=WARN + +# ActiveMQ web +logger.web.name=org.apache.activemq.web.handler +logger.web.level=WARN + +# Spring +logger.springframework.name=org.springframework +logger.springframework.level=WARN + +# XBean +logger.xbean.name=org.apache.xbean +logger.xbean.level=WARN + +# Jetty +logger.jetty.name=org.eclipse.jetty +logger.jetty.level=WARN + +# ActiveMQ +#log4j2.logger.activemq.name=org.apache.activemq +#log4j2.logger.activemq.level=DEBUG + +# Appender configuration + +# Console appender +appender.console.type=Console +appender.console.name=Console +appender.console.layout.type=PatternLayout +appender.console.layout.pattern=%5p | %m%n + +# File appender +appender.logfile.type=RollingRandomAccessFile +appender.logfile.name=RollingFile +appender.logfile.fileName=${sys:activemq.data}/activemq.log +appender.logfile.filePattern=${sys:activemq.data}/activemq.log.%i +appender.logfile.append=true +appender.logfile.layout.type=PatternLayout +appender.logfile.layout.pattern=%d | %-5p | %m | %c | %t%n%throwable{full} +appender.logfile.policies.type=Policies +appender.logfile.policies.size.type=SizeBasedTriggeringPolicy +appender.logfile.policies.size.size=1MB + +# you can control the rendering of exception in the pattern +# by default, we display the full stack trace +# if you want to display short form of the exception, you can use +# +# log4j2.appender.logfile.layout.pattern=%d | %-5p | %m | %c | %t%n%throwable{short} +# +# a classic issue with filebeat/logstash is about multiline exception. The following pattern +# allows to work smoothly with filebeat/logstash +# +# log4j2.appender.logfile.layout.pattern=%d | %-5p | %m | %c | %t%n%replace(%throwable){\n}{ } +# + +# use some of the following patterns to see MDC logging data +# +# %X{activemq.broker} +# %X{activemq.connector} +# %X{activemq.destination} +# +# e.g. +# +# log4j2.appender.logfile.layout.pattern=%d | %-20.20X{activemq.connector} | %-5p | %m | %c | %t%n + +########### +# Audit log +########### +logger.audit.name=org.apache.activemq.audit +logger.audit.additivity=false +logger.audit.level=INFO +logger.audit.appenderRef.auditlog.ref=AuditLog + +appender.auditlog.type=RollingRandomAccessFile +appender.auditlog.name=AuditLog +appender.auditlog.fileName=${sys:activemq.data}/audit.log +appender.auditlog.filePattern=${sys:activemq.data}/audit.log.%i +appender.auditlog.append=true +appender.auditlog.layout.type=PatternLayout +appender.auditlog.layout.pattern=%-5p | %m | %t%n +appender.auditlog.policies.type=Policies +appender.auditlog.policies.size.type=SizeBasedTriggeringPolicy +appender.auditlog.policies.size.size=1MB diff --git a/assembly/src/release/examples/conf/log4j.properties b/assembly/src/release/examples/conf/log4j2.properties similarity index 53% rename from assembly/src/release/examples/conf/log4j.properties rename to assembly/src/release/examples/conf/log4j2.properties index ac07489134..9e6448ca83 100644 --- a/assembly/src/release/examples/conf/log4j.properties +++ b/assembly/src/release/examples/conf/log4j2.properties @@ -18,22 +18,31 @@ # # The logging properties used by the standalone ActiveMQ broker # -log4j.rootLogger=INFO, stdout, logfile +rootLogger.level=INFO -# CONSOLE appender -log4j.appender.stdout=org.apache.log4j.ConsoleAppender -log4j.appender.stdout.layout=org.apache.log4j.PatternLayout -log4j.appender.stdout.layout.ConversionPattern=%d{HH:mm:ss} %-5p %m%n +rootLogger.appenderRef.console.ref=Console +rootLogger.appenderRef.logfile.ref=RollingFile -# Log File appender -log4j.appender.logfile=org.apache.log4j.FileAppender -log4j.appender.logfile.layout=org.apache.log4j.PatternLayout -log4j.appender.logfile.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n -log4j.appender.logfile.file=activemq.log -log4j.appender.logfile.append=true +logger.activemq.name=org.apache.activemq +logger.activemq.level=INFO -# -# You can change logger levels here. -# -log4j.logger.org.apache.activemq=INFO -log4j.logger.org.apache.activemq.spring=WARN +logger.spring.name=org.apache.activemq.spring +logger.spring.level=WARN + +# Console appender +appender.console.type=Console +appender.console.name=Console +appender.console.layout.type=PatternLayout +appender.console.layout.pattern=%d{HH:mm:ss} %-5p %m%n + +# RollingFile appender +appender.logfile.type=RollingRandomAccessFile +appender.logfile.name=RollingFile +appender.logfile.fileName=activemq.log +appender.logfile.filePattern=activemq.log.%i +appender.logfile.append=true +appender.logfile.layout.type=PatternLayout +appender.logfile.layout.pattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n +appender.logfile.policies.type=Policies +appender.logfile.policies.size.type=SizeBasedTriggeringPolicy +appender.logfile.policies.size.size=1MB \ No newline at end of file diff --git a/assembly/src/release/examples/openwire/advanced-scenarios/jms-example-queue/src/main/resources/log4j.properties b/assembly/src/release/examples/openwire/advanced-scenarios/jms-example-queue/src/main/resources/log4j2.properties similarity index 67% rename from assembly/src/release/examples/openwire/advanced-scenarios/jms-example-queue/src/main/resources/log4j.properties rename to assembly/src/release/examples/openwire/advanced-scenarios/jms-example-queue/src/main/resources/log4j2.properties index 211f9d445b..f23a98e884 100644 --- a/assembly/src/release/examples/openwire/advanced-scenarios/jms-example-queue/src/main/resources/log4j.properties +++ b/assembly/src/release/examples/openwire/advanced-scenarios/jms-example-queue/src/main/resources/log4j2.properties @@ -18,15 +18,20 @@ # # Setup the default logging levels # -log4j.rootLogger=INFO, console +rootLogger.level=INFO + +rootLogger.appenderRef.console.ref=Console +rootLogger.appenderRef.console.filter.threshold.type=ThresholdFilter +rootLogger.appenderRef.console.filter.threshold.level=TRACE # -# Uncomment one of the following to enable trace logging +# Uncomment to enable trace logging # -#log4j.logger.org.apache.activemq=TRACE +#logger.activemq.name=org.apache.activemq +#logger.activemq.level=TRACE -# Console Settings -log4j.appender.console=org.apache.log4j.ConsoleAppender -log4j.appender.console.layout=org.apache.log4j.PatternLayout -log4j.appender.console.layout.ConversionPattern=%C %-5p | %m%n -log4j.appender.console.threshold=TRACE +# Console appender +appender.console.type=Console +appender.console.name=Console +appender.console.layout.type=PatternLayout +appender.console.layout.pattern=%C %-5p | %m%n diff --git a/assembly/src/release/examples/openwire/advanced-scenarios/jms-example-topic/src/main/resources/log4j.properties b/assembly/src/release/examples/openwire/advanced-scenarios/jms-example-topic/src/main/resources/log4j2.properties similarity index 67% rename from assembly/src/release/examples/openwire/advanced-scenarios/jms-example-topic/src/main/resources/log4j.properties rename to assembly/src/release/examples/openwire/advanced-scenarios/jms-example-topic/src/main/resources/log4j2.properties index c901eac68a..f23a98e884 100644 --- a/assembly/src/release/examples/openwire/advanced-scenarios/jms-example-topic/src/main/resources/log4j.properties +++ b/assembly/src/release/examples/openwire/advanced-scenarios/jms-example-topic/src/main/resources/log4j2.properties @@ -18,15 +18,20 @@ # # Setup the default logging levels # -log4j.rootLogger=INFO, console +rootLogger.level=INFO + +rootLogger.appenderRef.console.ref=Console +rootLogger.appenderRef.console.filter.threshold.type=ThresholdFilter +rootLogger.appenderRef.console.filter.threshold.level=TRACE # -# Uncomment one of the following to enable debug logging +# Uncomment to enable trace logging # -#log4j.logger.org.apache.activemq=TRACE +#logger.activemq.name=org.apache.activemq +#logger.activemq.level=TRACE -# Console Settings -log4j.appender.console=org.apache.log4j.ConsoleAppender -log4j.appender.console.layout=org.apache.log4j.PatternLayout -log4j.appender.console.layout.ConversionPattern=%C %-5p | %m%n -log4j.appender.console.threshold=TRACE +# Console appender +appender.console.type=Console +appender.console.name=Console +appender.console.layout.type=PatternLayout +appender.console.layout.pattern=%C %-5p | %m%n diff --git a/assembly/src/test/resources/log4j.properties b/assembly/src/test/resources/log4j.properties deleted file mode 100644 index 1ab5a2b2ea..0000000000 --- a/assembly/src/test/resources/log4j.properties +++ /dev/null @@ -1,33 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- - -# -# The logging properties used during tests.. -# -log4j.rootLogger=INFO, stdout - -# CONSOLE appender not used by default -log4j.appender.stdout=org.apache.log4j.ConsoleAppender -log4j.appender.stdout.layout=org.apache.log4j.PatternLayout -log4j.appender.stdout.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n - -# File appender -log4j.appender.out=org.apache.log4j.FileAppender -log4j.appender.out.layout=org.apache.log4j.PatternLayout -log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n -log4j.appender.out.file=target/test-reports/activemq-test.log -log4j.appender.out.append=true diff --git a/activemq-log4j-appender/src/test/resources/jndi.properties b/assembly/src/test/resources/log4j2-test.properties similarity index 75% rename from activemq-log4j-appender/src/test/resources/jndi.properties rename to assembly/src/test/resources/log4j2-test.properties index 5739a94776..ba08a5028b 100644 --- a/activemq-log4j-appender/src/test/resources/jndi.properties +++ b/assembly/src/test/resources/log4j2-test.properties @@ -15,11 +15,15 @@ ## limitations under the License. ## --------------------------------------------------------------------------- -# START SNIPPET: jndi +# +# The logging properties used during tests +# +rootLogger.level=INFO -java.naming.factory.initial = org.apache.activemq.jndi.ActiveMQInitialContextFactory +rootLogger.appenderRef.console.ref=Console -# use the following property to configure the default connector -java.naming.provider.url = vm://localhost - -# END SNIPPET: jndi +# Console appender +appender.console.type=Console +appender.console.name=Console +appender.console.layout.type=PatternLayout +appender.console.layout.pattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n diff --git a/pom.xml b/pom.xml index b086514da5..d44c0d6a30 100644 --- a/pom.xml +++ b/pom.xml @@ -83,7 +83,7 @@ 4.13.2 1.3 4.2.11 - 1.2.17 + 2.17.1 3.8.0 5.2.4 1.16 @@ -99,7 +99,7 @@ 1.3 1.18.0 1.8.0 - 1.7.32 + 1.7.36 1.1.2 5.3.16 1.2.5 @@ -112,6 +112,7 @@ 0.12.0 1.19 + 1.11.4 4.13.1 2.6.2 5.6.12 @@ -121,7 +122,6 @@ 11 http://docs.oracle.com/javase/8/docs/api/ http://download.oracle.com/javaee/6/api/ - http://www.slf4j.org/apidocs/ 5.1.4 @@ -442,29 +442,6 @@ - - commons-logging - commons-logging - ${commons-logging-version} - - - avalon-framework - avalon-framework - - - logkit - logkit - - - log4j - log4j - - - javax.servlet - servlet-api - - - jakarta.jms @@ -529,6 +506,30 @@ + + commons-logging + commons-logging + ${commons-logging-version} + + + avalon-framework + avalon-framework + + + logkit + logkit + + + log4j + log4j + + + javax.servlet + servlet-api + + + + org.apache.camel camel-core @@ -571,10 +572,85 @@ ${osgi-version} + + org.ops4j.pax.logging + pax-logging-api + ${pax-logging-version} + + + org.ops4j.pax.logging + pax-logging-service + ${pax-logging-version} + + + log4j + apache-log4j-extras + + + + + org.ops4j.pax.logging + pax-logging-log4j2 + ${pax-logging-version} + + org.apache.hadoop.zookeeper zookeeper ${zookeeper-version} + + + io.netty + netty + + + org.slf4j + slf4j-log4j12 + + + log4j + log4j + + + + + org.apache.zookeeper + zookeeper + ${zookeeper-version} + + + io.netty + netty + + + org.slf4j + slf4j-log4j12 + + + log4j + log4j + + + + + org.linkedin + org.linkedin.zookeeper-impl + ${linkedin-zookeeper-version} + + + org.json + json + + + log4j + log4j + + + + + org.linkedin + org.linkedin.util-core + ${linkedin-zookeeper-version} @@ -639,10 +715,34 @@ - log4j - log4j + org.slf4j + slf4j-api + ${slf4j-version} + + + org.slf4j + jcl-over-slf4j + ${slf4j-version} + + + org.slf4j + slf4j-simple + ${slf4j-version} + + + org.apache.logging.log4j + log4j-api + ${log4j-version} + + + org.apache.logging.log4j + log4j-core + ${log4j-version} + + + org.apache.logging.log4j + log4j-slf4j-impl ${log4j-version} - runtime @@ -983,22 +1083,6 @@ ${mqtt-client-version} - - org.slf4j - slf4j-api - ${slf4j-version} - - - org.slf4j - slf4j-log4j12 - ${slf4j-version} - - - org.slf4j - jcl-over-slf4j - ${slf4j-version} - - org.apache.geronimo.components geronimo-transaction @@ -1398,7 +1482,6 @@ http://jakarta.apache.org/commons/dbcp/apidocs/ http://jakarta.apache.org/commons/fileupload/apidocs/ http://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/ - ${slf4j-javadoc-url} http://jakarta.apache.org/commons/pool/apidocs/ http://junit.sourceforge.net/javadoc/ http://logging.apache.org/log4j/docs/api/