[AMQ-7426] Upgrade to log4j2

This commit is contained in:
jbonofre 2021-05-27 11:30:59 +02:00 committed by Jean-Baptiste Onofré
parent 4715a01877
commit 472dcf8497
90 changed files with 1852 additions and 1474 deletions

View File

@ -60,12 +60,8 @@
<artifactId>geronimo-annotation_1.0_spec</artifactId> <artifactId>geronimo-annotation_1.0_spec</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.slf4j</groupId> <groupId>org.apache.logging.log4j</groupId>
<artifactId>slf4j-log4j12</artifactId> <artifactId>log4j-slf4j-impl</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
</dependency> </dependency>
</dependencies> </dependencies>
@ -109,9 +105,8 @@
<include>org.apache.geronimo.specs:geronimo-j2ee-management_1.1_spec</include> <include>org.apache.geronimo.specs:geronimo-j2ee-management_1.1_spec</include>
<include>org.apache.geronimo.specs:geronimo-annotation_1.0_spec</include> <include>org.apache.geronimo.specs:geronimo-annotation_1.0_spec</include>
<include>org.slf4j:slf4j-api</include> <include>org.slf4j:slf4j-api</include>
<include>org.slf4j:slf4j-log4j12</include> <include>org.apache.logging:log4j-slf4j-impl</include>
<include>org.slf4j:jcl-over-slf4j</include> <include>org.slf4j:jcl-over-slf4j</include>
<include>log4j:log4j</include>
<include>org.springframework:spring-core</include> <include>org.springframework:spring-core</include>
<include>org.springframework:spring-beans</include> <include>org.springframework:spring-beans</include>
<include>org.springframework:spring-context</include> <include>org.springframework:spring-context</include>
@ -347,15 +342,15 @@
<optional>true</optional> <optional>true</optional>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.slf4j</groupId> <groupId>org.apache.logging</groupId>
<artifactId>slf4j-log4j12</artifactId> <artifactId>log4j-slf4j-impl</artifactId>
<version>${slf4j-version}</version> <version>${log4j-version}</version>
<classifier>sources</classifier> <classifier>sources</classifier>
<optional>true</optional> <optional>true</optional>
</dependency> </dependency>
<dependency> <dependency>
<groupId>log4j</groupId> <groupId>org.apache.logging</groupId>
<artifactId>log4j</artifactId> <artifactId>log4j-api</artifactId>
<version>${log4j-version}</version> <version>${log4j-version}</version>
<classifier>sources</classifier> <classifier>sources</classifier>
<optional>true</optional> <optional>true</optional>

View File

@ -19,25 +19,42 @@
# This file controls most of the logging in ActiveMQ which is mainly based around # This file controls most of the logging in ActiveMQ which is mainly based around
# the commons logging API. # the commons logging API.
# #
log4j.rootLogger=INFO, console rootLogger.level=INFO
log4j.logger.org.apache.activemq.spring=WARN rootLogger.appenderRef.console.ref=Console
log4j.logger.org.apache.activemq.web.handler=WARN rootLogger.appenderRef.console.filter.threshold.type=ThresholdFilter
log4j.logger.org.springframework=WARN rootLogger.appenderRef.console.filter.threshold.level=INFO
log4j.logger.org.apache.xbean=WARN
log4j.logger.org.apache.camel=INFO logger.spring.name=org.apache.activemq.spring
log4j.logger.org.eclipse.jetty=WARN 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, # When debugging or reporting problems to the ActiveMQ team,
# comment out the above lines and uncomment the next. # 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 # Or for more fine grained debug logging uncomment one of these
#log4j.logger.org.apache.activemq=DEBUG #logger.activemq.name=org.apache.activemq
#log4j.logger.org.apache.camel=DEBUG #logger.activemq.level=DEBUG
#logger.camel.name=org.apache.camel
#logger.camel.level=DEBUG
# Console appender # Console appender
log4j.appender.console=org.apache.log4j.ConsoleAppender appender.console.type=Console
log4j.appender.console.layout=org.apache.log4j.PatternLayout appender.console.name=Console
log4j.appender.console.layout.ConversionPattern=%5p | %m%n appender.console.layout.type=PatternLayout
log4j.appender.console.threshold=INFO appender.console.layout.pattern=%5p | %m%n

View File

@ -130,8 +130,8 @@
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.slf4j</groupId> <groupId>org.apache.logging.log4j</groupId>
<artifactId>slf4j-log4j12</artifactId> <artifactId>log4j-slf4j-impl</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>

View File

@ -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

View File

@ -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

View File

@ -83,8 +83,13 @@
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.slf4j</groupId> <groupId>org.apache.logging.log4j</groupId>
<artifactId>slf4j-log4j12</artifactId> <artifactId>log4j-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
@ -105,7 +110,6 @@
<links> <links>
<link>${javase-javadoc-url}</link> <link>${javase-javadoc-url}</link>
<link>${javaee-javadoc-url}</link> <link>${javaee-javadoc-url}</link>
<link>${slf4j-javadoc-url}</link>
<link>http://junit.sourceforge.net/javadoc/</link> <link>http://junit.sourceforge.net/javadoc/</link>
</links> </links>
<stylesheetfile>${basedir}/../etc/css/stylesheet.css</stylesheetfile> <stylesheetfile>${basedir}/../etc/css/stylesheet.css</stylesheetfile>

View File

@ -17,52 +17,27 @@
package org.apache.activemq.util; package org.apache.activemq.util;
import org.apache.log4j.Appender; import org.apache.logging.log4j.core.Appender;
import org.apache.log4j.Layout; import org.apache.logging.log4j.core.ErrorHandler;
import org.apache.log4j.spi.ErrorHandler; import org.apache.logging.log4j.core.Layout;
import org.apache.log4j.spi.Filter; import org.apache.logging.log4j.core.LogEvent;
public abstract class DefaultTestAppender implements Appender { public abstract class DefaultTestAppender implements Appender {
String name = this.getClass().getSimpleName(); 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 @Override
public String getName() { public String getName() {
return name; return name;
} }
@Override @Override
public void setErrorHandler(ErrorHandler errorHandler) { public ErrorHandler getHandler() {
}
@Override
public ErrorHandler getErrorHandler() {
return null; return null;
} }
@Override @Override
public void setLayout(Layout layout) { public void setHandler(ErrorHandler handler) {
} }
@ -72,12 +47,42 @@ public abstract class DefaultTestAppender implements Appender {
} }
@Override @Override
public void setName(String name) { public void append(LogEvent event) {
this.name = name;
} }
@Override @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; return false;
} }
} }

View File

@ -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

View File

@ -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

View File

@ -80,8 +80,8 @@
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.slf4j</groupId> <groupId>org.apache.logging.log4j</groupId>
<artifactId>slf4j-log4j12</artifactId> <artifactId>log4j-slf4j-impl</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>

View File

@ -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

View File

@ -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

View File

@ -104,13 +104,13 @@
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.slf4j</groupId> <groupId>org.apache.logging.log4j</groupId>
<artifactId>slf4j-log4j12</artifactId> <artifactId>log4j-slf4j-impl</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>log4j</groupId> <groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j</artifactId> <artifactId>log4j-core</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
@ -165,10 +165,10 @@
<name>org.apache.activemq.default.directory.prefix</name> <name>org.apache.activemq.default.directory.prefix</name>
<value>target/</value> <value>target/</value>
</property> </property>
<!-- Uncomment the following if you want to configure custom logging (using src/test/resources/log4j.properties) <!-- Uncomment the following if you want to configure custom logging (using src/test/resources/log4j2-test.properties)
while running mvn:test Note: if you want to see log messages on the console window remove "redirectTestOutputToFile" while running mvn:test Note: if you want to see log messages on the console window remove "redirectTestOutputToFile"
from the parent pom --> from the parent pom -->
<!-- <property> <name>log4j.configuration</name> <value>file:target/test-classes/log4j.properties</value> <!-- <property> <name>log4j.configuration</name> <value>file:target/test-classes/log4j2-test.properties</value>
</property> --> </property> -->
</systemProperties> </systemProperties>
<includes> <includes>

View File

@ -67,7 +67,7 @@ public class Main {
// Parse for extension directory option // Parse for extension directory option
app.parseExtensions(tokens); 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 // in the activemq.classpath system property or some jar incorrectly includes one
File confDir = app.getActiveMQConfig(); File confDir = app.getActiveMQConfig();
app.addClassPath(confDir); app.addClassPath(confDir);

View File

@ -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

View File

@ -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

View File

@ -108,8 +108,8 @@
<optional>true</optional> <optional>true</optional>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.slf4j</groupId> <groupId>org.apache.logging.log4j</groupId>
<artifactId>slf4j-log4j12</artifactId> <artifactId>log4j-slf4j-impl</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>

View File

@ -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

View File

@ -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

View File

@ -73,13 +73,13 @@
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.slf4j</groupId> <groupId>org.apache.logging.log4j</groupId>
<artifactId>slf4j-log4j12</artifactId> <artifactId>log4j-slf4j-impl</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>log4j</groupId> <groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j</artifactId> <artifactId>log4j-core</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
</dependencies> </dependencies>

View File

@ -87,6 +87,12 @@
<artifactId>apacheds-server-integ</artifactId> <artifactId>apacheds-server-integ</artifactId>
<version>${directory-version}</version> <version>${directory-version}</version>
<scope>test</scope> <scope>test</scope>
<exclusions>
<exclusion>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</exclusion>
</exclusions>
</dependency> </dependency>
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>
@ -100,8 +106,8 @@
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>log4j</groupId> <groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j</artifactId> <artifactId>log4j-core</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
@ -109,8 +115,8 @@
<artifactId>slf4j-api</artifactId> <artifactId>slf4j-api</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.slf4j</groupId> <groupId>org.apache.logging.log4j</groupId>
<artifactId>slf4j-log4j12</artifactId> <artifactId>log4j-slf4j-impl</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>

View File

@ -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

View File

@ -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

View File

@ -79,8 +79,8 @@
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.slf4j</groupId> <groupId>org.apache.logging.log4j</groupId>
<artifactId>slf4j-log4j12</artifactId> <artifactId>log4j-slf4j-impl</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
@ -114,7 +114,7 @@
<name>org.apache.activemq.default.directory.prefix</name> <name>org.apache.activemq.default.directory.prefix</name>
<value>target/</value> <value>target/</value>
</property> </property>
<!-- Uncomment the following if you want to configure custom logging (using src/test/resources/log4j.properties) <!-- Uncomment the following if you want to configure custom logging (using src/test/resources/log4j2-test.properties)
while running mvn:test while running mvn:test
Note: if you want to see log messages on the console window remove Note: if you want to see log messages on the console window remove
"redirectTestOutputToFile" from the parent pom "redirectTestOutputToFile" from the parent pom
@ -122,7 +122,7 @@
<!-- <!--
<property> <property>
<name>log4j.configuration</name> <name>log4j.configuration</name>
<value>file:target/test-classes/log4j.properties</value> <value>file:target/test-classes/log4j2-test.properties</value>
</property> </property>
--> -->
</systemProperties> </systemProperties>

View File

@ -16,8 +16,6 @@
*/ */
package org.apache.activemq.store.jdbc.adapter; 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.junit.Assert.assertEquals;
import static org.mockito.Answers.RETURNS_DEEP_STUBS; import static org.mockito.Answers.RETURNS_DEEP_STUBS;
import static org.mockito.Mockito.inOrder; 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.Statements;
import org.apache.activemq.store.jdbc.TransactionContext; import org.apache.activemq.store.jdbc.TransactionContext;
import org.apache.activemq.util.DefaultTestAppender; import org.apache.logging.log4j.Level;
import org.apache.log4j.Level; import org.apache.logging.log4j.LogManager;
import org.apache.log4j.Logger; import org.apache.logging.log4j.core.LogEvent;
import org.apache.log4j.spi.LoggingEvent; import org.apache.logging.log4j.core.appender.AbstractAppender;
import org.junit.After; import org.apache.logging.log4j.core.config.Property;
import org.junit.Before; import org.apache.logging.log4j.core.filter.AbstractFilter;
import org.apache.logging.log4j.core.layout.MessageLayout;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.mockito.InOrder; import org.mockito.InOrder;
@ -46,7 +45,7 @@ import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner; import org.mockito.runners.MockitoJUnitRunner;
@RunWith(MockitoJUnitRunner.class) @RunWith(MockitoJUnitRunner.class)
public class DefaultJDBCAdapterDoCreateTablesTest { public class CommitsTheTransactionTest {
private static final String CREATE_STATEMENT1 = "createStatement1"; private static final String CREATE_STATEMENT1 = "createStatement1";
private static final String CREATE_STATEMENT2 = "createStatement2"; private static final String CREATE_STATEMENT2 = "createStatement2";
@ -57,7 +56,7 @@ public class DefaultJDBCAdapterDoCreateTablesTest {
private DefaultJDBCAdapter defaultJDBCAdapter; private DefaultJDBCAdapter defaultJDBCAdapter;
private List<LoggingEvent> loggingEvents = new ArrayList<>(); private List<LogEvent> loggingEvents = new ArrayList<>();
@Mock @Mock
private TransactionContext transactionContext; private TransactionContext transactionContext;
@ -74,18 +73,19 @@ public class DefaultJDBCAdapterDoCreateTablesTest {
@Mock @Mock
private Statement statement1, statement2; private Statement statement1, statement2;
@Before @Test
public void setUp() throws IOException, SQLException { public void commitsTheTransactionWhenAutoCommitIsDisabled() throws SQLException, IOException {
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 @Override
public void doAppend(LoggingEvent event) { public void append(LogEvent event) {
loggingEvents.add(event); loggingEvents.add(event.toImmutable());
} }
}; };
Logger rootLogger = Logger.getRootLogger(); appender.start();
rootLogger.setLevel(Level.DEBUG);
rootLogger.addAppender(appender);
logger.get().addAppender(appender, Level.DEBUG, new AbstractFilter() {});
logger.addAppender(appender);
defaultJDBCAdapter = new DefaultJDBCAdapter(); defaultJDBCAdapter = new DefaultJDBCAdapter();
defaultJDBCAdapter.statements = statements; 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.getMetaData().getTables(null, null, this.statements.getFullMessageTableName(),new String[] { "TABLE" })).thenReturn(resultSet);
when(connection.createStatement()).thenReturn(statement1, statement2); when(connection.createStatement()).thenReturn(statement1, statement2);
when(connection.getAutoCommit()).thenReturn(true); 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(connection.getAutoCommit()).thenReturn(false);
when(resultSet.next()).thenReturn(false); when(resultSet.next()).thenReturn(false);
@ -169,13 +114,15 @@ public class DefaultJDBCAdapterDoCreateTablesTest {
inOrder.verify(statement2).close(); inOrder.verify(statement2).close();
assertEquals(2, loggingEvents.size()); assertEquals(2, loggingEvents.size());
assertLog(0, DEBUG, "Executing SQL: " + CREATE_STATEMENT1); assertLog(0, Level.DEBUG, "Executing SQL: " + CREATE_STATEMENT1);
assertLog(1, DEBUG, "Executing SQL: " + CREATE_STATEMENT2); assertLog(1, Level.DEBUG, "Executing SQL: " + CREATE_STATEMENT2);
loggingEvents = new ArrayList<>();
} }
private void assertLog(int messageNumber, Level level, String message) { private void assertLog(int messageNumber, Level level, String message) {
LoggingEvent loggingEvent = loggingEvents.get(messageNumber); LogEvent loggingEvent = loggingEvents.get(messageNumber);
assertEquals(level, loggingEvent.getLevel()); assertEquals(level, loggingEvent.getLevel());
assertEquals(message, loggingEvent.getMessage()); assertEquals(message, loggingEvent.getMessage().getFormattedMessage());
} }
} }

View File

@ -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<LogEvent> 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());
}
}

View File

@ -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<LogEvent> 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());
}
}

View File

@ -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

View File

@ -89,13 +89,13 @@
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.slf4j</groupId> <groupId>org.apache.logging.log4j</groupId>
<artifactId>slf4j-log4j12</artifactId> <artifactId>log4j-slf4j-impl</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>log4j</groupId> <groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j</artifactId> <artifactId>log4j-core</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
</dependencies> </dependencies>

View File

@ -30,7 +30,8 @@ import javax.jms.JMSException;
import javax.jms.Session; import javax.jms.Session;
import org.apache.activemq.ActiveMQConnectionFactory; 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; import org.junit.Test;
/** /**
@ -40,7 +41,7 @@ import org.junit.Test;
*/ */
public class PooledConnectionFactoryMaximumActiveTest extends JmsPoolTestSupport { 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 Connection conn = null;
public static int sleepTimeout = 5000; public static int sleepTimeout = 5000;
@ -94,7 +95,7 @@ public class PooledConnectionFactoryMaximumActiveTest extends JmsPoolTestSupport
static class TestRunner2 implements Callable<Boolean> { static class TestRunner2 implements Callable<Boolean> {
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 * @return true if test succeeded, false otherwise

View File

@ -36,7 +36,8 @@ import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.activemq.broker.BrokerService; import org.apache.activemq.broker.BrokerService;
import org.apache.activemq.command.ConnectionId; import org.apache.activemq.command.ConnectionId;
import org.apache.activemq.util.Wait; 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 org.junit.Test;
import static org.junit.Assert.*; import static org.junit.Assert.*;
@ -52,7 +53,7 @@ import static org.junit.Assert.*;
*/ */
public class PooledConnectionFactoryTest extends JmsPoolTestSupport { 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) @Test(timeout = 60000)
public void testInstanceOf() throws Exception { public void testInstanceOf() throws Exception {
@ -345,7 +346,7 @@ public class PooledConnectionFactoryTest extends JmsPoolTestSupport {
static class TestRunner implements Callable<Boolean> { static class TestRunner implements Callable<Boolean> {
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 * @return true if test succeeded, false otherwise

View File

@ -38,7 +38,8 @@ import javax.jms.TextMessage;
import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.activemq.broker.BrokerService; import org.apache.activemq.broker.BrokerService;
import org.apache.activemq.broker.TransportConnector; 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.After;
import org.junit.Test; import org.junit.Test;
@ -46,7 +47,7 @@ public class PooledSessionExhaustionBlockTimeoutTest extends JmsPoolTestSupport
private static final String QUEUE = "FOO"; private static final String QUEUE = "FOO";
private static final int NUM_MESSAGES = 500; 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 ActiveMQConnectionFactory factory;
private PooledConnectionFactory pooledFactory; private PooledConnectionFactory pooledFactory;

View File

@ -36,7 +36,8 @@ import javax.jms.TextMessage;
import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.activemq.broker.BrokerService; import org.apache.activemq.broker.BrokerService;
import org.apache.activemq.broker.TransportConnector; 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.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
@ -46,7 +47,7 @@ public class PooledSessionExhaustionTest extends JmsPoolTestSupport {
private static final String QUEUE = "FOO"; private static final String QUEUE = "FOO";
private static final int NUM_MESSAGES = 500; 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 ActiveMQConnectionFactory factory;
private PooledConnectionFactory pooledFactory; private PooledConnectionFactory pooledFactory;

View File

@ -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

View File

@ -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

View File

@ -127,13 +127,8 @@
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.slf4j</groupId> <groupId>org.apache.logging.log4j</groupId>
<artifactId>slf4j-log4j12</artifactId> <artifactId>log4j-slf4j-impl</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>

View File

@ -50,13 +50,22 @@ import org.apache.activemq.util.ByteSequence;
import org.apache.activemq.util.DefaultTestAppender; import org.apache.activemq.util.DefaultTestAppender;
import org.apache.activemq.util.IOHelper; import org.apache.activemq.util.IOHelper;
import org.apache.activemq.util.RecoverableRandomAccessFile; import org.apache.activemq.util.RecoverableRandomAccessFile;
import org.apache.log4j.Level; import org.apache.logging.log4j.Level;
import org.apache.log4j.spi.LoggingEvent; 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.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.slf4j.event.LoggingEvent;
public class JournalCorruptionEofIndexRecoveryTest { public class JournalCorruptionEofIndexRecoveryTest {
@ -225,23 +234,27 @@ public class JournalCorruptionEofIndexRecoveryTest {
} }
AtomicBoolean trappedExpectedLogMessage = new AtomicBoolean(false); 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 @Override
public void doAppend(LoggingEvent event) { public void append(LogEvent event) {
if (event.getLevel() == Level.WARN if (event.getLevel() == Level.WARN
&& event.getRenderedMessage().contains("Cannot recover message audit") && event.getMessage().getFormattedMessage().contains("Cannot recover message audit")
&& event.getThrowableInformation().getThrowable().getLocalizedMessage().contains("Invalid location size")) { && event.getThrown().getLocalizedMessage().contains("Invalid location size")) {
trappedExpectedLogMessage.set(true); trappedExpectedLogMessage.set(true);
} }
} }
}; };
org.apache.log4j.Logger.getRootLogger().addAppender(appender); appender.start();
logger.addAppender(appender);
logger.get().addAppender(appender, Level.INFO, new AbstractFilter() {});
try { try {
restartBroker(false); restartBroker(false);
} finally { } finally {
org.apache.log4j.Logger.getRootLogger().removeAppender(appender); logger.removeAppender(appender);
logger.get().removeAppender("testAppender");
} }
assertEquals("no missing message", 50, broker.getAdminView().getTotalMessageCount()); assertEquals("no missing message", 50, broker.getAdminView().getTotalMessageCount());

View File

@ -18,11 +18,14 @@ package org.apache.activemq.store.kahadb.disk.page;
import junit.framework.TestCase; import junit.framework.TestCase;
import org.apache.activemq.store.kahadb.disk.util.StringMarshaller; import org.apache.activemq.store.kahadb.disk.util.StringMarshaller;
import org.apache.activemq.util.DefaultTestAppender;
import org.apache.activemq.util.Wait; import org.apache.activemq.util.Wait;
import org.apache.log4j.Appender; import org.apache.logging.log4j.Level;
import org.apache.log4j.Level; import org.apache.logging.log4j.LogManager;
import org.apache.log4j.spi.LoggingEvent; 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.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -365,19 +368,19 @@ public class PageFileTest extends TestCase {
final int numberOfPages = 1000; final int numberOfPages = 1000;
final AtomicBoolean recoveryEnd = new AtomicBoolean(); 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 @Override
public void doAppend(LoggingEvent event) { public void append(LogEvent event) {
if (event.getLevel().equals(Level.INFO) && event.getMessage().toString().contains("Recovered pageFile free list")) { if (event.toImmutable().getLevel().equals(Level.INFO) && event.toImmutable().getMessage().getFormattedMessage().contains("Recovered pageFile free list")) {
recoveryEnd.set(true); recoveryEnd.set(true);
} }
} }
}; };
appender.start();
org.apache.log4j.Logger log4jLogger = logger.addAppender(appender);
org.apache.log4j.Logger.getLogger(PageFile.class); logger.get().addAppender(appender, Level.DEBUG, new AbstractFilter() {});
log4jLogger.addAppender(appender);
log4jLogger.setLevel(Level.DEBUG);
PageFile pf = new PageFile(new File("target/test-data"), getName()); PageFile pf = new PageFile(new File("target/test-data"), getName());
pf.delete(); pf.delete();
@ -415,19 +418,18 @@ public class PageFileTest extends TestCase {
final int numberOfPages = 100000; final int numberOfPages = 100000;
final AtomicBoolean recoveryEnd = new AtomicBoolean(); 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 @Override
public void doAppend(LoggingEvent event) { public void append(LogEvent event) {
if (event.getLevel().equals(Level.INFO) && event.getMessage().toString().contains("Recovered pageFile free list")) { if (event.toImmutable().getLevel().equals(Level.INFO) && event.toImmutable().getMessage().getFormattedMessage().contains("Recovered pageFile free list")) {
recoveryEnd.set(true); recoveryEnd.set(true);
} }
} }
}; };
appender.start();
org.apache.log4j.Logger log4jLogger = logger.addAppender(appender);
org.apache.log4j.Logger.getLogger(PageFile.class); logger.get().addAppender(appender, Level.DEBUG, new AbstractFilter() {});
log4jLogger.addAppender(appender);
log4jLogger.setLevel(Level.DEBUG);
PageFile pf = new PageFile(new File("target/test-data"), getName()); PageFile pf = new PageFile(new File("target/test-data"), getName());
pf.delete(); pf.delete();
@ -499,7 +501,7 @@ public class PageFileTest extends TestCase {
pf2.flush(); pf2.flush();
long freePages = pf2.getFreePageCount(); long freePages = pf2.getFreePageCount();
LOG.info("free page count: " + freePages); LOG.info("free page count: " + freePages);
return recoveryEnd.get(); return recoveryEnd.get();
} }
}, 100000)); }, 100000));

View File

@ -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

View File

@ -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

View File

@ -46,18 +46,10 @@
<dependency> <dependency>
<groupId>org.ops4j.pax.logging</groupId> <groupId>org.ops4j.pax.logging</groupId>
<artifactId>pax-logging-api</artifactId> <artifactId>pax-logging-api</artifactId>
<version>1.11.4</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.ops4j.pax.logging</groupId> <groupId>org.ops4j.pax.logging</groupId>
<artifactId>pax-logging-service</artifactId> <artifactId>pax-logging-log4j2</artifactId>
<version>1.11.4</version>
<exclusions>
<exclusion>
<groupId>log4j</groupId>
<artifactId>apache-log4j-extras</artifactId>
</exclusion>
</exclusions>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.slf4j</groupId> <groupId>org.slf4j</groupId>
@ -65,8 +57,8 @@
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.slf4j</groupId> <groupId>org.apache.logging.log4j</groupId>
<artifactId>slf4j-log4j12</artifactId> <artifactId>log4j-slf4j-impl</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>

View File

@ -36,8 +36,8 @@
<artifactId>activemq-client</artifactId> <artifactId>activemq-client</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>log4j</groupId> <groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j</artifactId> <artifactId>log4j-core</artifactId>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
@ -50,8 +50,8 @@
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.slf4j</groupId> <groupId>org.apache.logging.log4j</groupId>
<artifactId>slf4j-log4j12</artifactId> <artifactId>log4j-slf4j-impl</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
@ -61,8 +61,33 @@
</dependency> </dependency>
</dependencies> </dependencies>
<build> <build>
<plugins> <plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<executions>
<execution>
<id>log4j-plugin-processor</id>
<goals>
<goal>compile</goal>
</goals>
<phase>process-classes</phase>
<configuration>
<proc>only</proc>
<annotationProcessors>
<annotationProcessor>org.apache.logging.log4j.core.config.plugins.processor.PluginProcessor</annotationProcessor>
</annotationProcessors>
</configuration>
</execution>
</executions>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin> <plugin>
<artifactId>maven-jar-plugin</artifactId> <artifactId>maven-jar-plugin</artifactId>
<configuration> <configuration>

View File

@ -16,6 +16,11 @@
*/ */
package org.apache.activemq.util; 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.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
@ -28,18 +33,12 @@ import javax.jms.MessageProducer;
import javax.jms.Session; import javax.jms.Session;
import javax.naming.NamingException; 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 * An abstract base class for implementation inheritence for a log4j JMS
* appender * appender
*
*
*/ */
public abstract class JmsLogAppenderSupport extends AppenderSkeleton { public abstract class JmsLogAppenderSupport extends AbstractAppender {
public static final int JMS_PUBLISH_ERROR_CODE = 61616;
private Connection connection; private Connection connection;
private Session session; private Session session;
@ -48,6 +47,11 @@ public abstract class JmsLogAppenderSupport extends AppenderSkeleton {
private String subjectPrefix = "log4j."; private String subjectPrefix = "log4j.";
public JmsLogAppenderSupport() { public JmsLogAppenderSupport() {
this("jmslog", (Filter) null);
}
protected JmsLogAppenderSupport(String name, Filter filter) {
super(name, filter, (Layout) null, true);
} }
public Connection getConnection() throws JMSException, NamingException { public Connection getConnection() throws JMSException, NamingException {
@ -108,7 +112,7 @@ public abstract class JmsLogAppenderSupport extends AppenderSkeleton {
} }
for (Iterator<JMSException> iter = errors.iterator(); iter.hasNext();) { for (Iterator<JMSException> iter = errors.iterator(); iter.hasNext();) {
JMSException e = iter.next(); 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 // lets ensure we're all created
getProducer(); getProducer();
} catch (Exception e) { } 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<Object> APPENDING = new ThreadLocal<Object>(); private static final ThreadLocal<Object> APPENDING = new ThreadLocal<Object>();
protected void append(LoggingEvent event) { public void append(LogEvent event) {
if( APPENDING.get()==null ) { if( APPENDING.get()==null ) {
APPENDING.set(true); APPENDING.set(true);
try { try {
@ -147,14 +151,14 @@ public abstract class JmsLogAppenderSupport extends AppenderSkeleton {
Destination destination = getDestination(event); Destination destination = getDestination(event);
getProducer().send(destination, message); getProducer().send(destination, message);
} catch (Exception e) { } 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 { } finally {
APPENDING.remove(); APPENDING.remove();
} }
} }
} }
protected Message createMessage(LoggingEvent event) throws JMSException, NamingException { protected Message createMessage(LogEvent event) throws JMSException, NamingException {
Message answer = null; Message answer = null;
Object value = event.getMessage(); Object value = event.getMessage();
if (allowTextMessages && value instanceof String) { if (allowTextMessages && value instanceof String) {
@ -163,12 +167,12 @@ public abstract class JmsLogAppenderSupport extends AppenderSkeleton {
answer = getSession().createObjectMessage((Serializable)value); answer = getSession().createObjectMessage((Serializable)value);
} }
answer.setStringProperty("level", event.getLevel().toString()); answer.setStringProperty("level", event.getLevel().toString());
answer.setIntProperty("levelInt", event.getLevel().toInt()); answer.setIntProperty("levelInt", event.getLevel().intLevel());
answer.setStringProperty("threadName", event.getThreadName()); answer.setStringProperty("threadName", event.getThreadName());
return answer; return answer;
} }
protected Destination getDestination(LoggingEvent event) throws JMSException, NamingException { protected Destination getDestination(LogEvent event) throws JMSException, NamingException {
String name = subjectPrefix + event.getLoggerName(); String name = subjectPrefix + event.getLoggerName();
return getSession().createTopic(name); return getSession().createTopic(name);
} }

View File

@ -24,8 +24,6 @@ import javax.naming.Context;
import javax.naming.InitialContext; import javax.naming.InitialContext;
import javax.naming.NamingException; 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 * A JMS 1.1 log4j appender which uses JNDI to locate a JMS ConnectionFactory to
* use for logging events. * use for logging events.
@ -117,7 +115,7 @@ public class JndiJmsLogAppender extends JmsLogAppenderSupport {
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
protected Connection createConnection() throws JMSException, NamingException { protected Connection createConnection() throws JMSException, NamingException {
InitialContext context = createInitialContext(); 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); ConnectionFactory factory = (ConnectionFactory)context.lookup(jndiName);
if (factory == null) { if (factory == null) {
throw new JMSException("No such ConnectionFactory for name: " + jndiName); throw new JMSException("No such ConnectionFactory for name: " + jndiName);
@ -138,7 +136,7 @@ public class JndiJmsLogAppender extends JmsLogAppenderSupport {
if (providerURL != null) { if (providerURL != null) {
env.put(Context.PROVIDER_URL, providerURL); env.put(Context.PROVIDER_URL, providerURL);
} else { } 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) { if (urlPkgPrefixes != null) {
env.put(Context.URL_PKG_PREFIXES, urlPkgPrefixes); env.put(Context.URL_PKG_PREFIXES, urlPkgPrefixes);
@ -149,10 +147,10 @@ public class JndiJmsLogAppender extends JmsLogAppenderSupport {
if (securityCredentials != null) { if (securityCredentials != null) {
env.put(Context.SECURITY_CREDENTIALS, securityCredentials); env.put(Context.SECURITY_CREDENTIALS, securityCredentials);
} else { } 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); return new InitialContext(env);
} }
} }

View File

@ -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);
}
}

View File

@ -153,13 +153,13 @@
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.slf4j</groupId> <groupId>org.apache.logging.log4j</groupId>
<artifactId>slf4j-log4j12</artifactId> <artifactId>log4j-slf4j-impl</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>log4j</groupId> <groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j</artifactId> <artifactId>log4j-core</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
</dependencies> </dependencies>

View File

@ -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

View File

@ -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

View File

@ -48,29 +48,18 @@
<dependency> <dependency>
<groupId>org.linkedin</groupId> <groupId>org.linkedin</groupId>
<artifactId>org.linkedin.zookeeper-impl</artifactId> <artifactId>org.linkedin.zookeeper-impl</artifactId>
<version>${linkedin-zookeeper-version}</version> </dependency>
<exclusions> <dependency>
<exclusion> <groupId>org.apache.logging.log4j</groupId>
<groupId>org.json</groupId> <artifactId>log4j-slf4j-impl</artifactId>
<artifactId>json</artifactId>
</exclusion>
</exclusions>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.linkedin</groupId> <groupId>org.linkedin</groupId>
<artifactId>org.linkedin.util-core</artifactId> <artifactId>org.linkedin.util-core</artifactId>
<version>${linkedin-zookeeper-version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.zookeeper</groupId> <groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId> <artifactId>zookeeper</artifactId>
<version>${zookeeper-version}</version>
<exclusions>
<exclusion>
<groupId>io.netty</groupId>
<artifactId>netty</artifactId>
</exclusion>
</exclusions>
</dependency> </dependency>
<!-- For Optional Snappy Compression --> <!-- For Optional Snappy Compression -->
@ -88,16 +77,6 @@
</dependency> </dependency>
<!-- Testing Dependencies --> <!-- Testing Dependencies -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<scope>test</scope>
</dependency>
<dependency> <dependency>
<groupId>org.apache.activemq</groupId> <groupId>org.apache.activemq</groupId>
<artifactId>activemq-broker</artifactId> <artifactId>activemq-broker</artifactId>

View File

@ -82,13 +82,13 @@
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.slf4j</groupId> <groupId>org.apache.logging.log4j</groupId>
<artifactId>slf4j-log4j12</artifactId> <artifactId>log4j-slf4j-impl</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>log4j</groupId> <groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j</artifactId> <artifactId>log4j-core</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>

View File

@ -75,8 +75,8 @@
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.slf4j</groupId> <groupId>org.apache.logging.log4j</groupId>
<artifactId>slf4j-log4j12</artifactId> <artifactId>log4j-slf4j-impl</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
</dependencies> </dependencies>

View File

@ -67,13 +67,13 @@ import org.apache.activemq.command.ActiveMQMessage;
import org.apache.activemq.command.ActiveMQQueue; import org.apache.activemq.command.ActiveMQQueue;
import org.apache.activemq.command.ConsumerInfo; import org.apache.activemq.command.ConsumerInfo;
import org.apache.activemq.util.Wait; import org.apache.activemq.util.Wait;
import org.apache.log4j.Appender; import org.apache.logging.log4j.Level;
import org.apache.log4j.Layout; import org.apache.logging.log4j.LogManager;
import org.apache.log4j.Level; import org.apache.logging.log4j.core.LogEvent;
import org.apache.log4j.LogManager; import org.apache.logging.log4j.core.appender.AbstractAppender;
import org.apache.log4j.spi.ErrorHandler; import org.apache.logging.log4j.core.config.Property;
import org.apache.log4j.spi.Filter; import org.apache.logging.log4j.core.filter.AbstractFilter;
import org.apache.log4j.spi.LoggingEvent; import org.apache.logging.log4j.core.layout.MessageLayout;
import org.junit.Test; import org.junit.Test;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -478,67 +478,20 @@ public class MDBTest {
brokerService.start(); brokerService.start();
final AtomicReference<String> errorMessage = new AtomicReference<String>(); final AtomicReference<String> errorMessage = new AtomicReference<String>();
final Appender testAppender = new Appender() { final var appender = new AbstractAppender("test", new AbstractFilter() {}, new MessageLayout(), false, new Property[0]) {
@Override @Override
public void addFilter(Filter filter) { public void append(LogEvent event) {
} if (event.getLevel().isMoreSpecificThan(Level.ERROR)) {
System.err.println("Event :" + event.getMessage().getFormattedMessage());
@Override errorMessage.set(event.getMessage().getFormattedMessage());
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());
} }
} }
@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); ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(brokerUrl);
Connection connection = factory.createConnection(); Connection connection = factory.createConnection();
@ -606,7 +559,9 @@ public class MDBTest {
assertNotNull("We got an error message", errorMessage.get()); assertNotNull("We got an error message", errorMessage.get());
assertTrue("correct message: " + errorMessage.get(), errorMessage.get().contains("zero")); assertTrue("correct message: " + errorMessage.get(), errorMessage.get().contains("zero"));
LogManager.getRootLogger().removeAppender(testAppender); logger.removeAppender(appender);
logger.get().removeAppender("test");
brokerService.stop(); brokerService.stop();
} }

View File

@ -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

View File

@ -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

View File

@ -340,12 +340,12 @@
<artifactId>activemq-mqtt</artifactId> <artifactId>activemq-mqtt</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>log4j</groupId> <groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j</artifactId> <artifactId>log4j-core</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.slf4j</groupId> <groupId>org.apache.logging.log4j</groupId>
<artifactId>slf4j-log4j12</artifactId> <artifactId>log4j-slf4j-impl</artifactId>
<scope>runtime</scope> <scope>runtime</scope>
</dependency> </dependency>
<dependency> <dependency>

View File

@ -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

View File

@ -15,8 +15,21 @@
## limitations under the License. ## limitations under the License.
## --------------------------------------------------------------------------- ## ---------------------------------------------------------------------------
# Make level to fatal so it would not affect the test case rootLogger.level=INFO
log4j.rootLogger=fatal, jms
log4j.appender.jms=org.apache.activemq.util.JndiJmsLogAppender rootLogger.appenderRef.console.ref=Console
log4j.appender.jms.jndiName=ConnectionFactory
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

View File

@ -82,13 +82,13 @@
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.slf4j</groupId> <groupId>org.apache.logging.log4j</groupId>
<artifactId>slf4j-log4j12</artifactId> <artifactId>log4j-slf4j-impl</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>log4j</groupId> <groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j</artifactId> <artifactId>log4j-core</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>

View File

@ -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

View File

@ -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

View File

@ -83,12 +83,6 @@
<type>test-jar</type> <type>test-jar</type>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>${commons-logging-version}</version>
<scope>test</scope>
</dependency>
<!-- <dependency> <!-- <dependency>
<groupId>${project.groupId}</groupId> <groupId>${project.groupId}</groupId>
<artifactId>activemq-jaas</artifactId> <artifactId>activemq-jaas</artifactId>
@ -100,13 +94,18 @@
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.slf4j</groupId> <groupId>org.apache.logging.log4j</groupId>
<artifactId>slf4j-log4j12</artifactId> <artifactId>log4j-slf4j-impl</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>log4j</groupId> <groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j</artifactId> <artifactId>log4j-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
</dependencies> </dependencies>
@ -163,7 +162,7 @@
<name>org.apache.activemq.default.directory.prefix</name> <name>org.apache.activemq.default.directory.prefix</name>
<value>target/</value> <value>target/</value>
</property> </property>
<!- - Uncomment the following if you want to configure custom logging (using src/test/resources/log4j.properties) <!- - Uncomment the following if you want to configure custom logging (using src/test/resources/log4j2-test.properties)
while running mvn:test while running mvn:test
Note: if you want to see log messages on the console window remove Note: if you want to see log messages on the console window remove
"redirectTestOutputToFile" from the parent pom "redirectTestOutputToFile" from the parent pom
@ -171,7 +170,7 @@
<!- - <!- -
<property> <property>
<name>log4j.configuration</name> <name>log4j.configuration</name>
<value>file:target/test-classes/log4j.properties</value> <value>file:target/test-classes/log4j2-test.properties</value>
</property> </property>
- -> - ->
</systemProperties> </systemProperties>

View File

@ -85,25 +85,16 @@
<dependency> <dependency>
<groupId>org.linkedin</groupId> <groupId>org.linkedin</groupId>
<artifactId>org.linkedin.zookeeper-impl</artifactId> <artifactId>org.linkedin.zookeeper-impl</artifactId>
<version>${linkedin-zookeeper-version}</version>
<scope>provided</scope> <scope>provided</scope>
<exclusions>
<exclusion>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
</exclusion>
</exclusions>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.linkedin</groupId> <groupId>org.linkedin</groupId>
<artifactId>org.linkedin.util-core</artifactId> <artifactId>org.linkedin.util-core</artifactId>
<version>${linkedin-zookeeper-version}</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.zookeeper</groupId> <groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId> <artifactId>zookeeper</artifactId>
<version>${zookeeper-version}</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
@ -118,7 +109,6 @@
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.activemq</groupId> <groupId>org.apache.activemq</groupId>
<artifactId>activemq-mqtt</artifactId> <artifactId>activemq-mqtt</artifactId>
@ -178,8 +168,8 @@
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>log4j</groupId> <groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j</artifactId> <artifactId>log4j-core</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
@ -189,8 +179,8 @@
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.slf4j</groupId> <groupId>org.apache.logging.log4j</groupId>
<artifactId>slf4j-log4j12</artifactId> <artifactId>log4j-slf4j-impl</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>

View File

@ -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.broker.region=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

View File

@ -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=INFO
rootLogger.appenderRef.console.ref=Console
rootLogger.appenderRef.logfile.ref=RollingFile
#logger.activemq.name=org.apache.activemq
#logger.activemq.level=DEBUG
#logger.region.name=org.apache.activemq.broker.region
#logger.region.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

View File

@ -90,13 +90,13 @@
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.slf4j</groupId> <groupId>org.apache.logging.log4j</groupId>
<artifactId>slf4j-log4j12</artifactId> <artifactId>log4j-slf4j-impl</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>log4j</groupId> <groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j</artifactId> <artifactId>log4j-core</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
</dependencies> </dependencies>

View File

@ -22,7 +22,8 @@ import java.io.IOException;
import java.net.Socket; import java.net.Socket;
import org.apache.activemq.command.ActiveMQQueue; import org.apache.activemq.command.ActiveMQQueue;
import org.apache.log4j.Appender; import org.apache.logging.log4j.core.Appender;
import org.apache.logging.log4j.core.LogEvent;
import org.junit.Test; import org.junit.Test;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -56,7 +57,7 @@ public class StompNIOSSLLargeMessageTest extends StompTestSupport {
protected Appender appender = new DefaultTestAppender() { protected Appender appender = new DefaultTestAppender() {
//@Override //@Override
@Override @Override
public void doAppend(org.apache.log4j.spi.LoggingEvent event) { public void append(LogEvent event) {
if (event.getMessage().toString().contains("<Unknown>") && if (event.getMessage().toString().contains("<Unknown>") &&
event.getMessage().toString().contains("The maximum data length was exceeded")) { event.getMessage().toString().contains("The maximum data length was exceeded")) {
gotUnknownOperationInLog = true; gotUnknownOperationInLog = true;
@ -89,7 +90,8 @@ public class StompNIOSSLLargeMessageTest extends StompTestSupport {
super.setUp(); super.setUp();
// register custom Log4J Appender // register custom Log4J Appender
org.apache.log4j.Logger.getRootLogger().addAppender(appender); org.apache.logging.log4j.core.Logger rootLogger = (org.apache.logging.log4j.core.Logger) org.apache.logging.log4j.LogManager.getRootLogger();
rootLogger.addAppender(appender);
stompConnect(); stompConnect();
connection = cf.createConnection("system", "manager"); connection = cf.createConnection("system", "manager");
@ -102,7 +104,8 @@ public class StompNIOSSLLargeMessageTest extends StompTestSupport {
@Override @Override
public void tearDown() throws Exception { public void tearDown() throws Exception {
// unregister Log4J appender // unregister Log4J appender
org.apache.log4j.Logger.getRootLogger().removeAppender(appender); org.apache.logging.log4j.core.Logger rootLogger = (org.apache.logging.log4j.core.Logger) org.apache.logging.log4j.LogManager.getRootLogger();
rootLogger.removeAppender(appender);
} }

View File

@ -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.transport=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

View File

@ -0,0 +1,47 @@
## ---------------------------------------------------------------------------
## 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.transport.name=org.apache.activemq.transport
logger.transport.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

View File

@ -16,14 +16,18 @@
## --------------------------------------------------------------------------- ## ---------------------------------------------------------------------------
# #
# The logging properties used during tests.. # The logging properties used during tests
# #
log4j.rootLogger=INFO, stdout rootLogger.level=INFO
log4j.logger.org.apache.activemq.tool=DEBUG rootLogger.appenderRef.console.ref=Console
# CONSOLE appender not used by default logger.tool.name=org.apache.activemq.tool
log4j.appender.stdout=org.apache.log4j.ConsoleAppender logger.tool.level=DEBUG
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d [%-15.15t] - %-5p %-30.30c{1} - %m%n # Console appender
#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 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

View File

@ -278,6 +278,12 @@
<artifactId>apacheds-server-integ</artifactId> <artifactId>apacheds-server-integ</artifactId>
<version>${directory-version}</version> <version>${directory-version}</version>
<scope>test</scope> <scope>test</scope>
<exclusions>
<exclusion>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</exclusion>
</exclusions>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.jmock</groupId> <groupId>org.jmock</groupId>

View File

@ -159,8 +159,8 @@
org.apache.commons.logging;version="[1.1,2)";resolution:=optional, org.apache.commons.logging;version="[1.1,2)";resolution:=optional,
org.slf4j;version="[1.6,2)";resolution:=optional, org.slf4j;version="[1.6,2)";resolution:=optional,
org.slf4j.spi;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;version="[2,3)";resolution:=optional,
org.apache.log4j.spi;version="[1.2.14,2)";resolution:=optional, org.apache.log4j.spi;version="[2,3)";resolution:=optional,
org.eclipse.jetty*;resolution:=optional;version="[9.0,10)", org.eclipse.jetty*;resolution:=optional;version="[9.0,10)",
org.objectweb.asm*;version="[6,8)" org.objectweb.asm*;version="[6,8)"
</Import-Package> </Import-Package>
@ -264,12 +264,12 @@
<artifactId>slf4j-api</artifactId> <artifactId>slf4j-api</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.slf4j</groupId> <groupId>org.apache.logging.log4j</groupId>
<artifactId>slf4j-log4j12</artifactId> <artifactId>log4j-slf4j-impl</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>log4j</groupId> <groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j</artifactId> <artifactId>log4j-core</artifactId>
</dependency> </dependency>
<!-- JSTL support --> <!-- JSTL support -->

View File

@ -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

View File

@ -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

View File

@ -126,8 +126,8 @@
org.apache.xbean*;version="[3.13,5)", org.apache.xbean*;version="[3.13,5)",
org.slf4j;version="[1.6,2)";resolution:=optional, org.slf4j;version="[1.6,2)";resolution:=optional,
org.slf4j.spi;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;version="[2,3)";resolution:=optional,
org.apache.log4j.spi;version="[1.2.14,2)";resolution:=optional org.apache.log4j.spi;version="[2,3)";resolution:=optional
</Import-Package> </Import-Package>
<Export-Package> <Export-Package>
!* !*
@ -178,6 +178,12 @@
<dependency> <dependency>
<groupId>${project.groupId}</groupId> <groupId>${project.groupId}</groupId>
<artifactId>activeio-core</artifactId> <artifactId>activeio-core</artifactId>
<exclusions>
<exclusion>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
</exclusion>
</exclusions>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.activemq</groupId> <groupId>org.apache.activemq</groupId>
@ -185,8 +191,8 @@
<optional>true</optional> <optional>true</optional>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.slf4j</groupId> <groupId>org.apache.logging.log4j</groupId>
<artifactId>slf4j-log4j12</artifactId> <artifactId>log4j-slf4j-impl</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -58,6 +58,10 @@
<groupId>commons-io</groupId> <groupId>commons-io</groupId>
<artifactId>commons-io</artifactId> <artifactId>commons-io</artifactId>
</dependency> </dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
</dependency>
<dependency> <dependency>
<groupId>${project.groupId}</groupId> <groupId>${project.groupId}</groupId>
<artifactId>activemq-unit-tests</artifactId> <artifactId>activemq-unit-tests</artifactId>
@ -129,8 +133,8 @@
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.slf4j</groupId> <groupId>org.apache.logging.log4j</groupId>
<artifactId>slf4j-log4j12</artifactId> <artifactId>log4j-slf4j-impl</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>

View File

@ -75,13 +75,6 @@
<dependency> <dependency>
<groupId>org.linkedin</groupId> <groupId>org.linkedin</groupId>
<artifactId>org.linkedin.zookeeper-impl</artifactId> <artifactId>org.linkedin.zookeeper-impl</artifactId>
<version>${linkedin-zookeeper-version}</version>
<exclusions>
<exclusion>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
</exclusion>
</exclusions>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.linkedin</groupId> <groupId>org.linkedin</groupId>
@ -91,13 +84,6 @@
<dependency> <dependency>
<groupId>org.apache.zookeeper</groupId> <groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId> <artifactId>zookeeper</artifactId>
<version>${zookeeper-version}</version>
<exclusions>
<exclusion>
<groupId>io.netty</groupId>
<artifactId>netty</artifactId>
</exclusion>
</exclusions>
</dependency> </dependency>
<dependency> <dependency>
@ -250,8 +236,12 @@
<artifactId>xpp3</artifactId> <artifactId>xpp3</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>log4j</groupId> <groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j</artifactId> <artifactId>log4j-core</artifactId>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>jakarta.jms</groupId> <groupId>jakarta.jms</groupId>
@ -361,26 +351,25 @@
</dependency> </dependency>
<!-- copied dependencies from activemq-web-console --> <!-- copied dependencies from activemq-web-console -->
<!-- enable commons-logging when inside jetty6:run -->
<dependency> <dependency>
<groupId>org.slf4j</groupId> <groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId> <artifactId>slf4j-api</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
</dependency>
<dependency> <dependency>
<groupId>org.slf4j</groupId> <groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId> <artifactId>jcl-over-slf4j</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.slf4j</groupId> <groupId>org.apache.geronimo.specs</groupId>
<artifactId>jcl-over-slf4j</artifactId> <artifactId>geronimo-annotation_1.0_spec</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.geronimo.specs</groupId> <groupId>org.ow2.asm</groupId>
<artifactId>geronimo-annotation_1.0_spec</artifactId> <artifactId>asm</artifactId>
</dependency>
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
</dependency> </dependency>
<dependency> <dependency>
@ -432,16 +421,6 @@
<artifactId>json-simple</artifactId> <artifactId>json-simple</artifactId>
<version>${json-simple-version}</version> <version>${json-simple-version}</version>
</dependency> </dependency>
<dependency>
<groupId>io.fabric8.insight</groupId>
<artifactId>insight-log-core</artifactId>
<version>${insight-version}</version>
</dependency>
<dependency>
<groupId>io.fabric8.insight</groupId>
<artifactId>insight-log4j</artifactId>
<version>${insight-version}</version>
</dependency>
<dependency> <dependency>
<groupId>org.ops4j.pax.url</groupId> <groupId>org.ops4j.pax.url</groupId>
<artifactId>pax-url-aether</artifactId> <artifactId>pax-url-aether</artifactId>

View File

@ -193,8 +193,9 @@
<include>org.apache.commons:commons-pool2</include> <include>org.apache.commons:commons-pool2</include>
<include>commons-codec:commons-codec</include> <include>commons-codec:commons-codec</include>
<include>org.apache.commons:commons-lang3</include> <include>org.apache.commons:commons-lang3</include>
<include>org.slf4j:slf4j-log4j12</include> <include>org.apache.logging.log4j:log4j-slf4j-impl</include>
<include>log4j:log4j</include> <include>org.apache.logging.log4j:log4j-api</include>
<include>org.apache.logging.log4j:log4j-core</include>
<include>org.apache.geronimo.specs:geronimo-j2ee-connector_1.5_spec</include> <include>org.apache.geronimo.specs:geronimo-j2ee-connector_1.5_spec</include>
<include>org.apache.httpcomponents:httpclient</include> <include>org.apache.httpcomponents:httpclient</include>
<include>org.apache.httpcomponents:httpcore</include> <include>org.apache.httpcomponents:httpcore</include>
@ -222,11 +223,6 @@
<!-- Apache Shiro dependencies: --> <!-- Apache Shiro dependencies: -->
<include>org.apache.shiro:shiro-core</include> <include>org.apache.shiro:shiro-core</include>
<include>org.apache.shiro:shiro-spring</include> <include>org.apache.shiro:shiro-spring</include>
<!-- insight log -->
<include>io.fabric8.insight:insight-log-core</include>
<include>io.fabric8.insight:insight-log4j</include>
</includes> </includes>
<fileMode>0644</fileMode> <fileMode>0644</fileMode>
<directoryMode>0755</directoryMode> <directoryMode>0755</directoryMode>

View File

@ -28,12 +28,6 @@
</property> </property>
</bean> </bean>
<!-- Allows accessing the server log -->
<bean id="logQuery" class="io.fabric8.insight.log.log4j.Log4jLogQuery"
lazy-init="false" scope="singleton"
init-method="start" destroy-method="stop">
</bean>
<!-- <!--
The <broker> element is used to configure the ActiveMQ broker. The <broker> element is used to configure the ActiveMQ broker.
--> -->

View File

@ -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

View File

@ -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

View File

@ -18,22 +18,31 @@
# #
# The logging properties used by the standalone ActiveMQ broker # The logging properties used by the standalone ActiveMQ broker
# #
log4j.rootLogger=INFO, stdout, logfile rootLogger.level=INFO
# CONSOLE appender rootLogger.appenderRef.console.ref=Console
log4j.appender.stdout=org.apache.log4j.ConsoleAppender rootLogger.appenderRef.logfile.ref=RollingFile
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{HH:mm:ss} %-5p %m%n
# Log File appender logger.activemq.name=org.apache.activemq
log4j.appender.logfile=org.apache.log4j.FileAppender logger.activemq.level=INFO
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.spring.name=org.apache.activemq.spring
# You can change logger levels here. logger.spring.level=WARN
#
log4j.logger.org.apache.activemq=INFO # Console appender
log4j.logger.org.apache.activemq.spring=WARN 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

View File

@ -18,15 +18,20 @@
# #
# Setup the default logging levels # 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 # Console appender
log4j.appender.console=org.apache.log4j.ConsoleAppender appender.console.type=Console
log4j.appender.console.layout=org.apache.log4j.PatternLayout appender.console.name=Console
log4j.appender.console.layout.ConversionPattern=%C %-5p | %m%n appender.console.layout.type=PatternLayout
log4j.appender.console.threshold=TRACE appender.console.layout.pattern=%C %-5p | %m%n

View File

@ -18,15 +18,20 @@
# #
# Setup the default logging levels # 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 # Console appender
log4j.appender.console=org.apache.log4j.ConsoleAppender appender.console.type=Console
log4j.appender.console.layout=org.apache.log4j.PatternLayout appender.console.name=Console
log4j.appender.console.layout.ConversionPattern=%C %-5p | %m%n appender.console.layout.type=PatternLayout
log4j.appender.console.threshold=TRACE appender.console.layout.pattern=%C %-5p | %m%n

View File

@ -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

View File

@ -15,11 +15,15 @@
## limitations under the License. ## 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 # Console appender
java.naming.provider.url = vm://localhost appender.console.type=Console
appender.console.name=Console
# END SNIPPET: jndi appender.console.layout.type=PatternLayout
appender.console.layout.pattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n

175
pom.xml
View File

@ -83,7 +83,7 @@
<junit-version>4.13.2</junit-version> <junit-version>4.13.2</junit-version>
<hamcrest-version>1.3</hamcrest-version> <hamcrest-version>1.3</hamcrest-version>
<karaf-version>4.2.11</karaf-version> <karaf-version>4.2.11</karaf-version>
<log4j-version>1.2.17</log4j-version> <log4j-version>2.17.1</log4j-version>
<mockito-version>3.8.0</mockito-version> <mockito-version>3.8.0</mockito-version>
<owasp-dependency-check-version>5.2.4</owasp-dependency-check-version> <owasp-dependency-check-version>5.2.4</owasp-dependency-check-version>
<mqtt-client-version>1.16</mqtt-client-version> <mqtt-client-version>1.16</mqtt-client-version>
@ -99,7 +99,7 @@
<regexp-version>1.3</regexp-version> <regexp-version>1.3</regexp-version>
<rome-version>1.16.0</rome-version> <rome-version>1.16.0</rome-version>
<shiro-version>1.8.0</shiro-version> <shiro-version>1.8.0</shiro-version>
<slf4j-version>1.7.32</slf4j-version> <slf4j-version>1.7.36</slf4j-version>
<snappy-version>1.1.2</snappy-version> <snappy-version>1.1.2</snappy-version>
<spring-version>5.3.16</spring-version> <spring-version>5.3.16</spring-version>
<taglibs-version>1.2.5</taglibs-version> <taglibs-version>1.2.5</taglibs-version>
@ -112,6 +112,7 @@
<jaxb-basics-version>0.12.0</jaxb-basics-version> <jaxb-basics-version>0.12.0</jaxb-basics-version>
<stompjms-version>1.19</stompjms-version> <stompjms-version>1.19</stompjms-version>
<pax-logging-version>1.11.4</pax-logging-version>
<pax-exam-version>4.13.1</pax-exam-version> <pax-exam-version>4.13.1</pax-exam-version>
<pax-url-version>2.6.2</pax-url-version> <pax-url-version>2.6.2</pax-url-version>
<felix-framework-version>5.6.12</felix-framework-version> <felix-framework-version>5.6.12</felix-framework-version>
@ -121,7 +122,6 @@
<target-version>11</target-version> <target-version>11</target-version>
<javase-javadoc-url>http://docs.oracle.com/javase/8/docs/api/</javase-javadoc-url> <javase-javadoc-url>http://docs.oracle.com/javase/8/docs/api/</javase-javadoc-url>
<javaee-javadoc-url>http://download.oracle.com/javaee/6/api/</javaee-javadoc-url> <javaee-javadoc-url>http://download.oracle.com/javaee/6/api/</javaee-javadoc-url>
<slf4j-javadoc-url>http://www.slf4j.org/apidocs/</slf4j-javadoc-url>
<!-- Maven Plugin Version for this Project --> <!-- Maven Plugin Version for this Project -->
<maven-bundle-plugin-version>5.1.4</maven-bundle-plugin-version> <maven-bundle-plugin-version>5.1.4</maven-bundle-plugin-version>
@ -442,29 +442,6 @@
<!-- =============================== --> <!-- =============================== -->
<!-- Required dependencies --> <!-- Required dependencies -->
<!-- =============================== --> <!-- =============================== -->
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>${commons-logging-version}</version>
<exclusions>
<exclusion>
<groupId>avalon-framework</groupId>
<artifactId>avalon-framework</artifactId>
</exclusion>
<exclusion>
<groupId>logkit</groupId>
<artifactId>logkit</artifactId>
</exclusion>
<exclusion>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</exclusion>
<exclusion>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency> <dependency>
<groupId>jakarta.jms</groupId> <groupId>jakarta.jms</groupId>
@ -529,6 +506,30 @@
<!-- Optional dependencies --> <!-- Optional dependencies -->
<!-- =============================== --> <!-- =============================== -->
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>${commons-logging-version}</version>
<exclusions>
<exclusion>
<groupId>avalon-framework</groupId>
<artifactId>avalon-framework</artifactId>
</exclusion>
<exclusion>
<groupId>logkit</groupId>
<artifactId>logkit</artifactId>
</exclusion>
<exclusion>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</exclusion>
<exclusion>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency> <dependency>
<groupId>org.apache.camel</groupId> <groupId>org.apache.camel</groupId>
<artifactId>camel-core</artifactId> <artifactId>camel-core</artifactId>
@ -571,10 +572,85 @@
<version>${osgi-version}</version> <version>${osgi-version}</version>
</dependency> </dependency>
<dependency>
<groupId>org.ops4j.pax.logging</groupId>
<artifactId>pax-logging-api</artifactId>
<version>${pax-logging-version}</version>
</dependency>
<dependency>
<groupId>org.ops4j.pax.logging</groupId>
<artifactId>pax-logging-service</artifactId>
<version>${pax-logging-version}</version>
<exclusions>
<exclusion>
<groupId>log4j</groupId>
<artifactId>apache-log4j-extras</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.ops4j.pax.logging</groupId>
<artifactId>pax-logging-log4j2</artifactId>
<version>${pax-logging-version}</version>
</dependency>
<dependency> <dependency>
<groupId>org.apache.hadoop.zookeeper</groupId> <groupId>org.apache.hadoop.zookeeper</groupId>
<artifactId>zookeeper</artifactId> <artifactId>zookeeper</artifactId>
<version>${zookeeper-version}</version> <version>${zookeeper-version}</version>
<exclusions>
<exclusion>
<groupId>io.netty</groupId>
<artifactId>netty</artifactId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
<exclusion>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
<version>${zookeeper-version}</version>
<exclusions>
<exclusion>
<groupId>io.netty</groupId>
<artifactId>netty</artifactId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
<exclusion>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.linkedin</groupId>
<artifactId>org.linkedin.zookeeper-impl</artifactId>
<version>${linkedin-zookeeper-version}</version>
<exclusions>
<exclusion>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
</exclusion>
<exclusion>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.linkedin</groupId>
<artifactId>org.linkedin.util-core</artifactId>
<version>${linkedin-zookeeper-version}</version>
</dependency> </dependency>
<!-- zeroconf transport --> <!-- zeroconf transport -->
@ -639,10 +715,34 @@
<!-- Used to configure the activemq logs --> <!-- Used to configure the activemq logs -->
<dependency> <dependency>
<groupId>log4j</groupId> <groupId>org.slf4j</groupId>
<artifactId>log4j</artifactId> <artifactId>slf4j-api</artifactId>
<version>${slf4j-version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>${slf4j-version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>${slf4j-version}</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>${log4j-version}</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>${log4j-version}</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<version>${log4j-version}</version> <version>${log4j-version}</version>
<scope>runtime</scope>
</dependency> </dependency>
<!-- used to support optional transport configuration via URI query strings --> <!-- used to support optional transport configuration via URI query strings -->
@ -983,22 +1083,6 @@
<version>${mqtt-client-version}</version> <version>${mqtt-client-version}</version>
</dependency> </dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j-version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>${slf4j-version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>${slf4j-version}</version>
</dependency>
<dependency> <dependency>
<groupId>org.apache.geronimo.components</groupId> <groupId>org.apache.geronimo.components</groupId>
<artifactId>geronimo-transaction</artifactId> <artifactId>geronimo-transaction</artifactId>
@ -1398,7 +1482,6 @@
<link>http://jakarta.apache.org/commons/dbcp/apidocs/</link> <link>http://jakarta.apache.org/commons/dbcp/apidocs/</link>
<link>http://jakarta.apache.org/commons/fileupload/apidocs/</link> <link>http://jakarta.apache.org/commons/fileupload/apidocs/</link>
<link>http://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/</link> <link>http://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/</link>
<link>${slf4j-javadoc-url}</link>
<link>http://jakarta.apache.org/commons/pool/apidocs/</link> <link>http://jakarta.apache.org/commons/pool/apidocs/</link>
<link>http://junit.sourceforge.net/javadoc/</link> <link>http://junit.sourceforge.net/javadoc/</link>
<link>http://logging.apache.org/log4j/docs/api/</link> <link>http://logging.apache.org/log4j/docs/api/</link>