This is an automated email from the ASF dual-hosted git repository. robertlazarski pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/axis-axis2-java-core.git
The following commit(s) were added to refs/heads/master by this push: new f0dade9 AXIS2-5993 upgrade entirely to log4j2 f0dade9 is described below commit f0dade92256ccecba1dd6d56dad49a50e8b5ba8e Author: Robert Lazarski <robertlazar...@gmail.com> AuthorDate: Thu Dec 3 07:40:46 2020 -1000 AXIS2-5993 upgrade entirely to log4j2 --- modules/distribution/pom.xml | 8 ++- .../src/main/assembly/bin-assembly.xml | 2 +- modules/integration/pom.xml | 13 +++-- .../axis2/engine/MessageContextSaveATest.java | 1 - .../axis2/engine/MessageContextSaveBTest.java | 1 - .../axis2/engine/MessageContextSaveCTest.java | 1 - .../engine/MessageContextSelfManagedDataTest.java | 1 - .../org/apache/axis2/engine/ObjectSave2Test.java | 1 - .../org/apache/axis2/engine/ObjectSaveTest.java | 1 - .../axis2/engine/OperationContextSaveTest.java | 1 - .../org/apache/axis2/engine/OptionsSaveTest.java | 1 - .../mtom/MessageSaveAndRestoreWithMTOMTest.java | 11 +++- modules/jaxws-integration/pom.xml | 9 +++- .../xmlhttp/DispatchXMessageDataSourceTests.java | 2 +- .../test-resources/log4j.properties | 60 ---------------------- .../jaxws-integration/test-resources/log4j2.xml | 22 ++++++++ modules/jaxws/pom.xml | 9 +++- modules/jaxws/test-resources/log4j.properties | 58 --------------------- modules/jaxws/test-resources/log4j2.xml | 22 ++++++++ .../apache/axis2/jaxws/message/SOAP12Tests.java | 8 ++- modules/kernel/conf/log4j.properties | 39 -------------- modules/kernel/conf/log4j2.xml | 22 ++++++++ modules/metadata/pom.xml | 9 +++- modules/metadata/test-resources/log4j.properties | 41 --------------- modules/metadata/test-resources/log4j2.xml | 22 ++++++++ .../AnnotationProviderImplDescriptionTests.java | 7 ++- .../AnnotationServiceImplDescriptionTests.java | 7 ++- .../AnnotationServiceImplWithDBCTests.java | 1 - .../jaxws/description/ServiceAnnotationTests.java | 7 ++- .../jaxws/description/WrapperPackageTests.java | 10 ++-- .../converter/ReflectiveConverterTests.java | 7 ++- modules/saaj/pom.xml | 13 ++++- modules/saaj/test-resources/log4j.properties | 42 --------------- modules/saaj/test-resources/log4j2.xml | 22 ++++++++ modules/samples/book/src/main/log4j.properties | 39 -------------- modules/samples/book/src/main/log4j2.xml | 44 ++++++++++++++++ .../src/webapp/WEB-INF/classes/log4j.properties | 40 --------------- .../src/webapp/WEB-INF/classes/log4j2.xml | 44 ++++++++++++++++ .../src/webapp/WEB-INF/classes/log4j.properties | 40 --------------- .../src/webapp/WEB-INF/classes/log4j2.xml | 44 ++++++++++++++++ .../src/test/resources/log4j.properties | 40 --------------- modules/tool/axis2-idea-plugin/pom.xml | 8 ++- modules/tool/axis2-wsdl2code-maven-plugin/pom.xml | 4 +- .../src/test/resources/log4j.properties | 40 --------------- modules/transport/jms/pom.xml | 2 +- .../org/apache/axis2/transport/jms/LogAspect.java | 4 +- modules/transport/mail/pom.xml | 2 +- .../transport/mail/GreenMailTestEnvironment.java | 6 +-- .../org/apache/axis2/transport/mail/LogAspect.java | 4 +- modules/transport/tcp/pom.xml | 2 +- modules/transport/testkit/pom.xml | 10 ++++ .../axis2/transport/testkit/ManagedTestSuite.java | 4 +- .../axis2/transport/testkit/axis2/LogAspect.java | 16 +++--- .../testkit/axis2/endpoint/AxisTestEndpoint.java | 4 +- .../testkit/http/JettyByteArrayAsyncEndpoint.java | 6 +-- .../axis2/transport/testkit/package-info.java | 6 +-- .../transport/testkit/tests/ManagedTestCase.java | 10 ++-- .../{LogManager.java => TestKitLogManager.java} | 55 +++++++++++++------- modules/webapp/pom.xml | 8 ++- pom.xml | 31 ++++++++--- src/site/xdoc/docs/modules.xml | 5 -- src/site/xdoc/docs/userguide.xml | 2 +- 62 files changed, 451 insertions(+), 550 deletions(-) diff --git a/modules/distribution/pom.xml b/modules/distribution/pom.xml index db33dea..f08fede 100755 --- a/modules/distribution/pom.xml +++ b/modules/distribution/pom.xml @@ -266,8 +266,12 @@ on our users. However, for the binary distribution, we need to choose one. --> <dependency> - <groupId>log4j</groupId> - <artifactId>log4j</artifactId> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-api</artifactId> + </dependency> + <dependency> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-core</artifactId> </dependency> <!-- This is needed to build the WAR distribution --> diff --git a/modules/distribution/src/main/assembly/bin-assembly.xml b/modules/distribution/src/main/assembly/bin-assembly.xml index 683bfe4..c926d22 100755 --- a/modules/distribution/src/main/assembly/bin-assembly.xml +++ b/modules/distribution/src/main/assembly/bin-assembly.xml @@ -102,7 +102,7 @@ <directory>../../modules/kernel/conf</directory> <outputDirectory>conf</outputDirectory> <includes> - <include>log4j.properties</include> + <include>log4j2.xml</include> <include>commons-logging.properties</include> </includes> </fileSet> diff --git a/modules/integration/pom.xml b/modules/integration/pom.xml index c8be617..79775be 100644 --- a/modules/integration/pom.xml +++ b/modules/integration/pom.xml @@ -114,9 +114,16 @@ <scope>test</scope> </dependency> <dependency> - <groupId>log4j</groupId> - <artifactId>log4j</artifactId> - <scope>test</scope> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-api</artifactId> + </dependency> + <dependency> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-core</artifactId> + </dependency> + <dependency> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-slf4j-impl</artifactId> </dependency> <dependency> <groupId>commons-httpclient</groupId> diff --git a/modules/integration/test/org/apache/axis2/engine/MessageContextSaveATest.java b/modules/integration/test/org/apache/axis2/engine/MessageContextSaveATest.java index 1473ead..99db027 100644 --- a/modules/integration/test/org/apache/axis2/engine/MessageContextSaveATest.java +++ b/modules/integration/test/org/apache/axis2/engine/MessageContextSaveATest.java @@ -299,7 +299,6 @@ public class MessageContextSaveATest extends TestCase { protected void setUp() throws Exception { - //org.apache.log4j.BasicConfigurator.configure(); } diff --git a/modules/integration/test/org/apache/axis2/engine/MessageContextSaveBTest.java b/modules/integration/test/org/apache/axis2/engine/MessageContextSaveBTest.java index 3913078..cd9e2f5 100644 --- a/modules/integration/test/org/apache/axis2/engine/MessageContextSaveBTest.java +++ b/modules/integration/test/org/apache/axis2/engine/MessageContextSaveBTest.java @@ -547,7 +547,6 @@ public class MessageContextSaveBTest extends TestCase { } protected void setUp() throws Exception { - //org.apache.log4j.BasicConfigurator.configure(); } public void testServiceProperties() throws Exception { diff --git a/modules/integration/test/org/apache/axis2/engine/MessageContextSaveCTest.java b/modules/integration/test/org/apache/axis2/engine/MessageContextSaveCTest.java index 1b890b6..2c5cf9f 100644 --- a/modules/integration/test/org/apache/axis2/engine/MessageContextSaveCTest.java +++ b/modules/integration/test/org/apache/axis2/engine/MessageContextSaveCTest.java @@ -541,7 +541,6 @@ public class MessageContextSaveCTest extends TestCase { } protected void setUp() throws Exception { - //org.apache.log4j.BasicConfigurator.configure(); } public void testHierarchyNewContext() throws Exception { diff --git a/modules/integration/test/org/apache/axis2/engine/MessageContextSelfManagedDataTest.java b/modules/integration/test/org/apache/axis2/engine/MessageContextSelfManagedDataTest.java index d088e37..56fd4ed 100644 --- a/modules/integration/test/org/apache/axis2/engine/MessageContextSelfManagedDataTest.java +++ b/modules/integration/test/org/apache/axis2/engine/MessageContextSelfManagedDataTest.java @@ -269,7 +269,6 @@ public class MessageContextSelfManagedDataTest extends TestCase { * for their respective functions. */ protected void setUp() throws Exception { - //org.apache.log4j.BasicConfigurator.configure(); invokecallcount = 0; diff --git a/modules/integration/test/org/apache/axis2/engine/ObjectSave2Test.java b/modules/integration/test/org/apache/axis2/engine/ObjectSave2Test.java index 3248240..c745359 100644 --- a/modules/integration/test/org/apache/axis2/engine/ObjectSave2Test.java +++ b/modules/integration/test/org/apache/axis2/engine/ObjectSave2Test.java @@ -54,7 +54,6 @@ public class ObjectSave2Test extends TestCase { } protected void setUp() throws Exception { - // org.apache.log4j.BasicConfigurator.configure(); } public void testObjectSerializable() throws Exception { diff --git a/modules/integration/test/org/apache/axis2/engine/ObjectSaveTest.java b/modules/integration/test/org/apache/axis2/engine/ObjectSaveTest.java index 0a367e1..7ecfa75 100644 --- a/modules/integration/test/org/apache/axis2/engine/ObjectSaveTest.java +++ b/modules/integration/test/org/apache/axis2/engine/ObjectSaveTest.java @@ -53,7 +53,6 @@ public class ObjectSaveTest extends TestCase { } protected void setUp() throws Exception { - // org.apache.log4j.BasicConfigurator.configure(); } public void testObjectSerializable() throws Exception { diff --git a/modules/integration/test/org/apache/axis2/engine/OperationContextSaveTest.java b/modules/integration/test/org/apache/axis2/engine/OperationContextSaveTest.java index 0087618..3ae94d8 100644 --- a/modules/integration/test/org/apache/axis2/engine/OperationContextSaveTest.java +++ b/modules/integration/test/org/apache/axis2/engine/OperationContextSaveTest.java @@ -227,7 +227,6 @@ public class OperationContextSaveTest extends TestCase { protected void setUp() throws Exception { - //org.apache.log4j.BasicConfigurator.configure(); } diff --git a/modules/integration/test/org/apache/axis2/engine/OptionsSaveTest.java b/modules/integration/test/org/apache/axis2/engine/OptionsSaveTest.java index 3b845bf..5344562 100644 --- a/modules/integration/test/org/apache/axis2/engine/OptionsSaveTest.java +++ b/modules/integration/test/org/apache/axis2/engine/OptionsSaveTest.java @@ -62,7 +62,6 @@ public class OptionsSaveTest extends TestCase { protected void setUp() throws Exception { - //org.apache.log4j.BasicConfigurator.configure(); } public void testSaveAndRestore() throws Exception { diff --git a/modules/integration/test/org/apache/axis2/mtom/MessageSaveAndRestoreWithMTOMTest.java b/modules/integration/test/org/apache/axis2/mtom/MessageSaveAndRestoreWithMTOMTest.java index ff47686..b16db20 100644 --- a/modules/integration/test/org/apache/axis2/mtom/MessageSaveAndRestoreWithMTOMTest.java +++ b/modules/integration/test/org/apache/axis2/mtom/MessageSaveAndRestoreWithMTOMTest.java @@ -49,6 +49,10 @@ import org.apache.axis2.integration.UtilServerBasedTestCase; import org.apache.axis2.phaseresolver.PhaseMetadata; import org.apache.axis2.util.Utils; +import org.apache.logging.log4j.core.config.Configurator; +import org.apache.logging.log4j.core.config.DefaultConfiguration; +import org.apache.logging.log4j.Level; + import javax.activation.DataHandler; import javax.activation.FileDataSource; import javax.imageio.ImageIO; @@ -73,13 +77,16 @@ public class MessageSaveAndRestoreWithMTOMTest extends UtilServerBasedTestCase public MessageSaveAndRestoreWithMTOMTest() { super(MessageSaveAndRestoreWithMTOMTest.class.getName()); - org.apache.log4j.BasicConfigurator.configure(); + Configurator.initialize(new DefaultConfiguration()); + Configurator.setRootLevel(Level.DEBUG); + } public MessageSaveAndRestoreWithMTOMTest(String testName) { super(testName); - org.apache.log4j.BasicConfigurator.configure(); + Configurator.initialize(new DefaultConfiguration()); + Configurator.setRootLevel(Level.DEBUG); } public static Test suite() { diff --git a/modules/jaxws-integration/pom.xml b/modules/jaxws-integration/pom.xml index 82f686e..08499fb 100644 --- a/modules/jaxws-integration/pom.xml +++ b/modules/jaxws-integration/pom.xml @@ -97,8 +97,13 @@ <scope>test</scope> </dependency> <dependency> - <groupId>log4j</groupId> - <artifactId>log4j</artifactId> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-api</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-core</artifactId> <scope>test</scope> </dependency> </dependencies> diff --git a/modules/jaxws-integration/src/test/java/org/apache/axis2/jaxws/xmlhttp/DispatchXMessageDataSourceTests.java b/modules/jaxws-integration/src/test/java/org/apache/axis2/jaxws/xmlhttp/DispatchXMessageDataSourceTests.java index 5430bcf..9936615 100644 --- a/modules/jaxws-integration/src/test/java/org/apache/axis2/jaxws/xmlhttp/DispatchXMessageDataSourceTests.java +++ b/modules/jaxws-integration/src/test/java/org/apache/axis2/jaxws/xmlhttp/DispatchXMessageDataSourceTests.java @@ -86,7 +86,7 @@ public class DispatchXMessageDataSourceTests { }; String resourceDir = System.getProperty("basedir",".")+"/"+"test-resources"; - File file3 = new File(resourceDir+File.separator+"log4j.properties"); + File file3 = new File(resourceDir+File.separator+"log4j2.xml"); attachmentDS = new FileDataSource(file3); } diff --git a/modules/jaxws-integration/test-resources/log4j.properties b/modules/jaxws-integration/test-resources/log4j.properties deleted file mode 100644 index b18d4bf..0000000 --- a/modules/jaxws-integration/test-resources/log4j.properties +++ /dev/null @@ -1,60 +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. -# - -# Set root category priority to INFO and its only appender to CONSOLE. -#log4j.rootCategory=DEBUG, CONSOLE -#log4j.rootCategory=DEBUG, CONSOLE, LOGFILE -#log4j.rootCategory=DEBUG, LOGFILE -log4j.rootCategory=ERROR, CONSOLE - -# Set selected logging -# (You might want to do this to cut down on the size of the file) -# The example below adds debug trace for StAXUtils or jaxws server to -# the axis2.small.log. -# You can add this without changing the root category. -#log4j.category.org.apache.axiom.om.util.StAXUtils=DEBUG, SMALL -#log4j.category.org.apache.axis2.jaxws.message.databinding.JAXBUtils=DEBUG, SMALL - -# Enable the following to get JAXWS TestLogger trace. -#log4j.category.JAXWS-Tests=DEBUG, SMALL - -# Set the enterprise logger priority to FATAL -log4j.logger.org.apache.axis2.enterprise=FATAL -log4j.logger.httpclient.wire.header=FATAL -log4j.logger.org.apache.commons.httpclient=FATAL - - -# CONSOLE is set to be a ConsoleAppender using a PatternLayout. -log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender -log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout -log4j.appender.CONSOLE.layout.ConversionPattern=%d %-5p %c - %m%n - -# LOGFILE is set to be a File appender using a PatternLayout. -log4j.appender.LOGFILE=org.apache.log4j.FileAppender -log4j.appender.LOGFILE.File=axis2.log -log4j.appender.LOGFILE.Append=true -log4j.appender.LOGFILE.layout=org.apache.log4j.PatternLayout -log4j.appender.LOGFILE.layout.ConversionPattern=%d [%t] %-5p %c %x - %m%n - -# SMALL is set to be a File appender using a PatternLayout. -log4j.appender.SMALL=org.apache.log4j.FileAppender -log4j.appender.SMALL.File=axis2.small.log -log4j.appender.SMALL.Append=true -log4j.appender.SMALL.layout=org.apache.log4j.PatternLayout -log4j.appender.SMALL.layout.ConversionPattern=%d [%t] %-5p %c %x - %m%n diff --git a/modules/jaxws-integration/test-resources/log4j2.xml b/modules/jaxws-integration/test-resources/log4j2.xml new file mode 100644 index 0000000..6decd11 --- /dev/null +++ b/modules/jaxws-integration/test-resources/log4j2.xml @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="UTF-8"?> +<Configuration status="debug" name="axis2" packages=""> + <Appenders> + <Console name="Console" target="SYSTEM_OUT"> + <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/> + </Console> + </Appenders> + <Loggers> + <Logger name="org.apache" level="warn" additivity="false" > + <AppenderRef ref="Console"/> + </Logger> + <Logger name="org.apache.axis2" level="debug" additivity="false" > + <AppenderRef ref="Console"/> + </Logger> + <Logger name="org.springframework" level="warn" additivity="false" > + <AppenderRef ref="Console"/> + </Logger> + <Root level="debug"> + <AppenderRef ref="Console"/> + </Root> + </Loggers> +</Configuration> diff --git a/modules/jaxws/pom.xml b/modules/jaxws/pom.xml index 12f4e0c..5372704 100644 --- a/modules/jaxws/pom.xml +++ b/modules/jaxws/pom.xml @@ -114,8 +114,13 @@ <scope>test</scope> </dependency> <dependency> - <groupId>log4j</groupId> - <artifactId>log4j</artifactId> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-api</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-core</artifactId> <scope>test</scope> </dependency> <dependency> diff --git a/modules/jaxws/test-resources/log4j.properties b/modules/jaxws/test-resources/log4j.properties deleted file mode 100644 index 59f798e..0000000 --- a/modules/jaxws/test-resources/log4j.properties +++ /dev/null @@ -1,58 +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. -# - -# Set root category priority to INFO and its only appender to CONSOLE. -#log4j.rootCategory=DEBUG, CONSOLE -#log4j.rootCategory=DEBUG, CONSOLE, LOGFILE -#log4j.rootCategory=DEBUG, LOGFILE -log4j.rootCategory=ERROR, CONSOLE - -# Set selected logging -# (You might want to do this to cut down on the size of the file) -# The example below adds debug trace for StAXUtils or jaxws server to -# the axis2.small.log. -# You can add this without changing the root category. -#log4j.category.org.apache.axis2.jaxws.message=DEBUG, SMALL - -# Enable the following to get JAXWS TestLogger trace. -#log4j.category.JAXWS-Tests=DEBUG, SMALL - -# Set the enterprise logger priority to FATAL -log4j.logger.org.apache.axis2.enterprise=FATAL -log4j.logger.httpclient.wire.header=FATAL -log4j.logger.org.apache.commons.httpclient=FATAL - -# CONSOLE is set to be a ConsoleAppender using a PatternLayout. -log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender -log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout -log4j.appender.CONSOLE.layout.ConversionPattern=%d %-5p %c - %m%n - -# LOGFILE is set to be a File appender using a PatternLayout. -log4j.appender.LOGFILE=org.apache.log4j.FileAppender -log4j.appender.LOGFILE.File=axis2.log -log4j.appender.LOGFILE.Append=true -log4j.appender.LOGFILE.layout=org.apache.log4j.PatternLayout -log4j.appender.LOGFILE.layout.ConversionPattern=%d [%t] %-5p %c %x - %m%n - -# SMALL is set to be a File appender using a PatternLayout. -log4j.appender.SMALL=org.apache.log4j.FileAppender -log4j.appender.SMALL.File=axis2.small.log -log4j.appender.SMALL.Append=true -log4j.appender.SMALL.layout=org.apache.log4j.PatternLayout -log4j.appender.SMALL.layout.ConversionPattern=%d [%t] %-5p %c %x - %m%n diff --git a/modules/jaxws/test-resources/log4j2.xml b/modules/jaxws/test-resources/log4j2.xml new file mode 100644 index 0000000..6decd11 --- /dev/null +++ b/modules/jaxws/test-resources/log4j2.xml @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="UTF-8"?> +<Configuration status="debug" name="axis2" packages=""> + <Appenders> + <Console name="Console" target="SYSTEM_OUT"> + <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/> + </Console> + </Appenders> + <Loggers> + <Logger name="org.apache" level="warn" additivity="false" > + <AppenderRef ref="Console"/> + </Logger> + <Logger name="org.apache.axis2" level="debug" additivity="false" > + <AppenderRef ref="Console"/> + </Logger> + <Logger name="org.springframework" level="warn" additivity="false" > + <AppenderRef ref="Console"/> + </Logger> + <Root level="debug"> + <AppenderRef ref="Console"/> + </Root> + </Loggers> +</Configuration> diff --git a/modules/jaxws/test/org/apache/axis2/jaxws/message/SOAP12Tests.java b/modules/jaxws/test/org/apache/axis2/jaxws/message/SOAP12Tests.java index 8e88666..9588056 100644 --- a/modules/jaxws/test/org/apache/axis2/jaxws/message/SOAP12Tests.java +++ b/modules/jaxws/test/org/apache/axis2/jaxws/message/SOAP12Tests.java @@ -29,7 +29,10 @@ import org.apache.axis2.jaxws.message.factory.MessageFactory; import org.apache.axis2.jaxws.message.factory.XMLStringBlockFactory; import org.apache.axis2.jaxws.registry.FactoryRegistry; import org.apache.axis2.jaxws.unitTest.TestLogger; -import org.apache.log4j.BasicConfigurator; + +import org.apache.logging.log4j.core.config.Configurator; +import org.apache.logging.log4j.core.config.DefaultConfiguration; +import org.apache.logging.log4j.Level; import javax.xml.stream.XMLInputFactory; import javax.xml.stream.XMLStreamReader; @@ -67,7 +70,8 @@ public class SOAP12Tests extends TestCase { } static { - BasicConfigurator.configure(); + Configurator.initialize(new DefaultConfiguration()); + Configurator.setRootLevel(Level.DEBUG); } /** diff --git a/modules/kernel/conf/log4j.properties b/modules/kernel/conf/log4j.properties deleted file mode 100755 index 4814a72..0000000 --- a/modules/kernel/conf/log4j.properties +++ /dev/null @@ -1,39 +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. -# - -# Set root category priority to INFO and its only appender to CONSOLE. -log4j.rootCategory=INFO, CONSOLE -#log4j.rootCategory=INFO, CONSOLE, LOGFILE - -# Set the enterprise logger priority to FATAL -log4j.logger.org.apache.axis2.enterprise=FATAL -log4j.logger.httpclient.wire.header=FATAL -log4j.logger.org.apache.commons.httpclient=FATAL - -# CONSOLE is set to be a ConsoleAppender using a PatternLayout. -log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender -log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout -log4j.appender.CONSOLE.layout.ConversionPattern=[%p] %m%n - -# LOGFILE is set to be a File appender using a PatternLayout. -log4j.appender.LOGFILE=org.apache.log4j.FileAppender -log4j.appender.LOGFILE.File=axis2.log -log4j.appender.LOGFILE.Append=true -log4j.appender.LOGFILE.layout=org.apache.log4j.PatternLayout -log4j.appender.LOGFILE.layout.ConversionPattern=%d [%t] %-5p %c %x - %m%n diff --git a/modules/kernel/conf/log4j2.xml b/modules/kernel/conf/log4j2.xml new file mode 100644 index 0000000..6decd11 --- /dev/null +++ b/modules/kernel/conf/log4j2.xml @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="UTF-8"?> +<Configuration status="debug" name="axis2" packages=""> + <Appenders> + <Console name="Console" target="SYSTEM_OUT"> + <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/> + </Console> + </Appenders> + <Loggers> + <Logger name="org.apache" level="warn" additivity="false" > + <AppenderRef ref="Console"/> + </Logger> + <Logger name="org.apache.axis2" level="debug" additivity="false" > + <AppenderRef ref="Console"/> + </Logger> + <Logger name="org.springframework" level="warn" additivity="false" > + <AppenderRef ref="Console"/> + </Logger> + <Root level="debug"> + <AppenderRef ref="Console"/> + </Root> + </Loggers> +</Configuration> diff --git a/modules/metadata/pom.xml b/modules/metadata/pom.xml index 4e80f0f..ed1d2ca 100755 --- a/modules/metadata/pom.xml +++ b/modules/metadata/pom.xml @@ -65,8 +65,13 @@ <scope>test</scope> </dependency> <dependency> - <groupId>log4j</groupId> - <artifactId>log4j</artifactId> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-api</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-core</artifactId> <scope>test</scope> </dependency> <dependency> diff --git a/modules/metadata/test-resources/log4j.properties b/modules/metadata/test-resources/log4j.properties deleted file mode 100644 index 9808688..0000000 --- a/modules/metadata/test-resources/log4j.properties +++ /dev/null @@ -1,41 +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. -# - -# Set root category priority to INFO and its only appender to CONSOLE. -#log4j.rootCategory=DEBUG, CONSOLE -#log4j.rootCategory=INFO, CONSOLE, LOGFILE -#log4j.rootCategory=INFO, CONSOLE -log4j.rootCategory=ERROR, CONSOLE - -# Set the enterprise logger priority to FATAL -log4j.logger.org.apache.axis2.enterprise=FATAL -log4j.logger.httpclient.wire.header=FATAL -log4j.logger.org.apache.commons.httpclient=FATAL - -# CONSOLE is set to be a ConsoleAppender using a PatternLayout. -log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender -log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout -log4j.appender.CONSOLE.layout.ConversionPattern=%d %-5p %c - %m%n - -# LOGFILE is set to be a File appender using a PatternLayout. -log4j.appender.LOGFILE=org.apache.log4j.FileAppender -log4j.appender.LOGFILE.File=axis2.log -log4j.appender.LOGFILE.Append=true -log4j.appender.LOGFILE.layout=org.apache.log4j.PatternLayout -log4j.appender.LOGFILE.layout.ConversionPattern=%d [%t] %-5p %c %x - %m%n diff --git a/modules/metadata/test-resources/log4j2.xml b/modules/metadata/test-resources/log4j2.xml new file mode 100644 index 0000000..6decd11 --- /dev/null +++ b/modules/metadata/test-resources/log4j2.xml @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="UTF-8"?> +<Configuration status="debug" name="axis2" packages=""> + <Appenders> + <Console name="Console" target="SYSTEM_OUT"> + <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/> + </Console> + </Appenders> + <Loggers> + <Logger name="org.apache" level="warn" additivity="false" > + <AppenderRef ref="Console"/> + </Logger> + <Logger name="org.apache.axis2" level="debug" additivity="false" > + <AppenderRef ref="Console"/> + </Logger> + <Logger name="org.springframework" level="warn" additivity="false" > + <AppenderRef ref="Console"/> + </Logger> + <Root level="debug"> + <AppenderRef ref="Console"/> + </Root> + </Loggers> +</Configuration> diff --git a/modules/metadata/test/org/apache/axis2/jaxws/description/AnnotationProviderImplDescriptionTests.java b/modules/metadata/test/org/apache/axis2/jaxws/description/AnnotationProviderImplDescriptionTests.java index 4edfe9d..962a2be 100644 --- a/modules/metadata/test/org/apache/axis2/jaxws/description/AnnotationProviderImplDescriptionTests.java +++ b/modules/metadata/test/org/apache/axis2/jaxws/description/AnnotationProviderImplDescriptionTests.java @@ -21,7 +21,9 @@ package org.apache.axis2.jaxws.description; import junit.framework.TestCase; import org.apache.axis2.jaxws.description.builder.MDQConstants; -import org.apache.log4j.BasicConfigurator; +import org.apache.logging.log4j.core.config.Configurator; +import org.apache.logging.log4j.core.config.DefaultConfiguration; +import org.apache.logging.log4j.Level; import javax.jws.WebService; import javax.xml.soap.SOAPMessage; @@ -39,7 +41,8 @@ public class AnnotationProviderImplDescriptionTests extends TestCase { // -Xmx512m. This can be done by setting maven.junit.jvmargs in project.properties. // To change the settings, edit the log4j.property file // in the test-resources directory. - BasicConfigurator.configure(); + Configurator.initialize(new DefaultConfiguration()); + Configurator.setRootLevel(Level.DEBUG); } diff --git a/modules/metadata/test/org/apache/axis2/jaxws/description/AnnotationServiceImplDescriptionTests.java b/modules/metadata/test/org/apache/axis2/jaxws/description/AnnotationServiceImplDescriptionTests.java index 85b1cf2..68ae729 100644 --- a/modules/metadata/test/org/apache/axis2/jaxws/description/AnnotationServiceImplDescriptionTests.java +++ b/modules/metadata/test/org/apache/axis2/jaxws/description/AnnotationServiceImplDescriptionTests.java @@ -32,7 +32,9 @@ import org.apache.axis2.jaxws.description.impl.EndpointDescriptionImpl; import org.apache.axis2.jaxws.description.impl.EndpointInterfaceDescriptionImpl; import org.apache.axis2.jaxws.description.impl.LegacyMethodRetrieverImpl; import org.apache.axis2.jaxws.util.WSToolingUtils; -import org.apache.log4j.BasicConfigurator; +import org.apache.logging.log4j.core.config.Configurator; +import org.apache.logging.log4j.core.config.DefaultConfiguration; +import org.apache.logging.log4j.Level; import javax.jws.Oneway; import javax.jws.WebMethod; @@ -58,7 +60,8 @@ public class AnnotationServiceImplDescriptionTests extends TestCase { // -Xmx512m. This can be done by setting maven.junit.jvmargs in project.properties. // To change the settings, edit the log4j.property file // in the test-resources directory. - BasicConfigurator.configure(); + Configurator.initialize(new DefaultConfiguration()); + Configurator.setRootLevel(Level.DEBUG); } /** diff --git a/modules/metadata/test/org/apache/axis2/jaxws/description/AnnotationServiceImplWithDBCTests.java b/modules/metadata/test/org/apache/axis2/jaxws/description/AnnotationServiceImplWithDBCTests.java index 7b27c92..c500567 100644 --- a/modules/metadata/test/org/apache/axis2/jaxws/description/AnnotationServiceImplWithDBCTests.java +++ b/modules/metadata/test/org/apache/axis2/jaxws/description/AnnotationServiceImplWithDBCTests.java @@ -51,7 +51,6 @@ public class AnnotationServiceImplWithDBCTests extends TestCase { //Test creation of a Service Description from DBC, using a basic list. //An implicit SEI that extends only java.lang.object public void testServiceImplAsImplicitSEI() { - //org.apache.log4j.BasicConfigurator.configure(); //Build a Hashmap of DescriptionBuilderComposites that contains the serviceImpl and //all necessary associated DBC's possibly including SEI and superclasses diff --git a/modules/metadata/test/org/apache/axis2/jaxws/description/ServiceAnnotationTests.java b/modules/metadata/test/org/apache/axis2/jaxws/description/ServiceAnnotationTests.java index 7f68789..4cb1395 100644 --- a/modules/metadata/test/org/apache/axis2/jaxws/description/ServiceAnnotationTests.java +++ b/modules/metadata/test/org/apache/axis2/jaxws/description/ServiceAnnotationTests.java @@ -20,7 +20,9 @@ package org.apache.axis2.jaxws.description; import junit.framework.TestCase; -import org.apache.log4j.BasicConfigurator; +import org.apache.logging.log4j.core.config.Configurator; +import org.apache.logging.log4j.core.config.DefaultConfiguration; +import org.apache.logging.log4j.Level; import javax.jws.WebService; import javax.xml.ws.Provider; @@ -32,7 +34,8 @@ public class ServiceAnnotationTests extends TestCase { // -Xmx512m. This can be done by setting maven.junit.jvmargs in project.properties. // To change the settings, edit the log4j.property file // in the test-resources directory. - BasicConfigurator.configure(); + Configurator.initialize(new DefaultConfiguration()); + Configurator.setRootLevel(Level.DEBUG); } public void testWebServiceDefaults() { diff --git a/modules/metadata/test/org/apache/axis2/jaxws/description/WrapperPackageTests.java b/modules/metadata/test/org/apache/axis2/jaxws/description/WrapperPackageTests.java index f6164e3..315916c 100644 --- a/modules/metadata/test/org/apache/axis2/jaxws/description/WrapperPackageTests.java +++ b/modules/metadata/test/org/apache/axis2/jaxws/description/WrapperPackageTests.java @@ -20,7 +20,9 @@ package org.apache.axis2.jaxws.description; import junit.framework.TestCase; -import org.apache.log4j.BasicConfigurator; +import org.apache.logging.log4j.core.config.Configurator; +import org.apache.logging.log4j.core.config.DefaultConfiguration; +import org.apache.logging.log4j.Level; import javax.jws.WebService; import javax.xml.ws.RequestWrapper; @@ -34,7 +36,9 @@ public class WrapperPackageTests extends TestCase { // -Xmx512m. This can be done by setting maven.junit.jvmargs in project.properties. // To change the settings, edit the log4j.property file // in the test-resources directory. - BasicConfigurator.configure(); + Configurator.initialize(new DefaultConfiguration()); + Configurator.setRootLevel(Level.DEBUG); + } public void testSEIPackageWrapper() { @@ -153,4 +157,4 @@ class SEISubPackageWrapper { public String subPackageMethod1(String string) throws SubPackageException { return string; } -} \ No newline at end of file +} diff --git a/modules/metadata/test/org/apache/axis2/jaxws/description/builder/converter/ReflectiveConverterTests.java b/modules/metadata/test/org/apache/axis2/jaxws/description/builder/converter/ReflectiveConverterTests.java index b2c85b0..3dbcdf3 100644 --- a/modules/metadata/test/org/apache/axis2/jaxws/description/builder/converter/ReflectiveConverterTests.java +++ b/modules/metadata/test/org/apache/axis2/jaxws/description/builder/converter/ReflectiveConverterTests.java @@ -25,7 +25,9 @@ import org.apache.axis2.jaxws.description.builder.MethodDescriptionComposite; import org.apache.axis2.jaxws.description.builder.ParameterDescriptionComposite; import org.apache.axis2.jaxws.description.builder.WebMethodAnnot; import org.apache.axis2.jaxws.description.builder.WebParamAnnot; -import org.apache.log4j.BasicConfigurator; +import org.apache.logging.log4j.core.config.Configurator; +import org.apache.logging.log4j.core.config.DefaultConfiguration; +import org.apache.logging.log4j.Level; import javax.jws.WebMethod; import javax.jws.WebParam; @@ -42,7 +44,8 @@ public class ReflectiveConverterTests extends TestCase { // -Xmx512m. This can be done by setting maven.junit.jvmargs in project.properties. // To change the settings, edit the log4j.property file // in the test-resources directory. - BasicConfigurator.configure(); + Configurator.initialize(new DefaultConfiguration()); + Configurator.setRootLevel(Level.DEBUG); } private static DescriptionBuilderComposite implDBC; diff --git a/modules/saaj/pom.xml b/modules/saaj/pom.xml index 684bfa6..b3f1821 100644 --- a/modules/saaj/pom.xml +++ b/modules/saaj/pom.xml @@ -91,8 +91,17 @@ <scope>test</scope> </dependency> <dependency> - <groupId>log4j</groupId> - <artifactId>log4j</artifactId> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-jcl</artifactId> + </dependency> + <dependency> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-api</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-core</artifactId> <scope>test</scope> </dependency> <dependency> diff --git a/modules/saaj/test-resources/log4j.properties b/modules/saaj/test-resources/log4j.properties deleted file mode 100644 index 869707a..0000000 --- a/modules/saaj/test-resources/log4j.properties +++ /dev/null @@ -1,42 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -# Set root category priority to INFO and its only appender to CONSOLE. -#log4j.rootCategory=DEBUG, CONSOLE -#log4j.rootCategory=INFO, CONSOLE, LOGFILE -#log4j.rootCategory=DEBUG, LOGFILE -log4j.rootCategory=ERROR, CONSOLE - - -# Set the enterprise logger priority to FATAL -log4j.logger.org.apache.axis2.enterprise=FATAL -log4j.logger.httpclient.wire.header=FATAL -log4j.logger.org.apache.commons.httpclient=FATAL - -# CONSOLE is set to be a ConsoleAppender using a PatternLayout. -log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender -log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout -log4j.appender.CONSOLE.layout.ConversionPattern=%d %-5p %c - %m%n - -# LOGFILE is set to be a File appender using a PatternLayout. -log4j.appender.LOGFILE=org.apache.log4j.FileAppender -log4j.appender.LOGFILE.File=axis2.log -log4j.appender.LOGFILE.Append=true -log4j.appender.LOGFILE.layout=org.apache.log4j.PatternLayout -log4j.appender.LOGFILE.layout.ConversionPattern=%d [%t] %-5p %c %x - %m%n diff --git a/modules/saaj/test-resources/log4j2.xml b/modules/saaj/test-resources/log4j2.xml new file mode 100644 index 0000000..6decd11 --- /dev/null +++ b/modules/saaj/test-resources/log4j2.xml @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="UTF-8"?> +<Configuration status="debug" name="axis2" packages=""> + <Appenders> + <Console name="Console" target="SYSTEM_OUT"> + <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/> + </Console> + </Appenders> + <Loggers> + <Logger name="org.apache" level="warn" additivity="false" > + <AppenderRef ref="Console"/> + </Logger> + <Logger name="org.apache.axis2" level="debug" additivity="false" > + <AppenderRef ref="Console"/> + </Logger> + <Logger name="org.springframework" level="warn" additivity="false" > + <AppenderRef ref="Console"/> + </Logger> + <Root level="debug"> + <AppenderRef ref="Console"/> + </Root> + </Loggers> +</Configuration> diff --git a/modules/samples/book/src/main/log4j.properties b/modules/samples/book/src/main/log4j.properties deleted file mode 100644 index 3a33724..0000000 --- a/modules/samples/book/src/main/log4j.properties +++ /dev/null @@ -1,39 +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. -# - -# Set root category priority to INFO and its only appender to CONSOLE. -log4j.rootCategory=INFO, CONSOLE -#log4j.rootCategory=INFO, CONSOLE, LOGFILE - -# Set the enterprise logger priority to FATAL -log4j.logger.org.apache.axis2.enterprise=FATAL -log4j.logger.httpclient.wire.header=FATAL -log4j.logger.org.apache.commons.httpclient=FATAL - -# CONSOLE is set to be a ConsoleAppender using a PatternLayout. -log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender -log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout -log4j.appender.CONSOLE.layout.ConversionPattern=%d %-5p %c - %m%n - -# LOGFILE is set to be a File appender using a PatternLayout. -log4j.appender.LOGFILE=org.apache.log4j.FileAppender -log4j.appender.LOGFILE.File=axis2.log -log4j.appender.LOGFILE.Append=true -log4j.appender.LOGFILE.layout=org.apache.log4j.PatternLayout -log4j.appender.LOGFILE.layout.ConversionPattern=%d [%t] %-5p %c %x - %m%n diff --git a/modules/samples/book/src/main/log4j2.xml b/modules/samples/book/src/main/log4j2.xml new file mode 100644 index 0000000..d2e94ac --- /dev/null +++ b/modules/samples/book/src/main/log4j2.xml @@ -0,0 +1,44 @@ +<?xml version="1.0" encoding="UTF-8"?> +<Configuration status="debug" name="axis2" packages=""> + <Appenders> + <Console name="Console" target="SYSTEM_OUT"> + <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/> + </Console> + <RollingFile name="RollingFile" append="true" fileName="axis2.log" filePattern="axis2-%i.log.gz"> + <PatternLayout> + <Pattern>%d %p %c{1.} [%t] %m%n</Pattern> + </PatternLayout> + <Policies> + <OnStartupTriggeringPolicy/> + <SizeBasedTriggeringPolicy size="20 MB"/> + </Policies> + <DefaultRolloverStrategy max="10"> + <Delete basePath="${baseDir}" > + <IfFileName glob="*.log.*"> + <IfAny> + <IfLastModified age="5d" />- + </IfAny> + </IfFileName> + </Delete> + </DefaultRolloverStrategy> + </RollingFile> + </Appenders> + <Loggers> + <Logger name="org.apache" level="warn" additivity="false" > + <AppenderRef ref="RollingFile"/> + <AppenderRef ref="Console"/> + </Logger> + <Logger name="org.apache.axis2" level="debug" additivity="false" > + <AppenderRef ref="RollingFile"/> + <AppenderRef ref="Console"/> + </Logger> + <Logger name="org.springframework" level="warn" additivity="false" > + <AppenderRef ref="RollingFile"/> + <AppenderRef ref="Console"/> + </Logger> + <Root level="debug"> + <AppenderRef ref="Console"/> + <AppenderRef ref="RollingFile"/> + </Root> + </Loggers> +</Configuration> diff --git a/modules/samples/java_first_jaxws/src/webapp/WEB-INF/classes/log4j.properties b/modules/samples/java_first_jaxws/src/webapp/WEB-INF/classes/log4j.properties deleted file mode 100644 index ad3d8a7..0000000 --- a/modules/samples/java_first_jaxws/src/webapp/WEB-INF/classes/log4j.properties +++ /dev/null @@ -1,40 +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. -# - - -# Set root category priority to INFO and its only appender to CONSOLE. -log4j.rootCategory=INFO, CONSOLE -#log4j.rootCategory=INFO, CONSOLE, LOGFILE - -# Set the enterprise logger priority to FATAL -log4j.logger.org.apache.axis2.enterprise=FATAL -log4j.logger.httpclient.wire.header=FATAL -log4j.logger.org.apache.commons.httpclient=FATAL - -# CONSOLE is set to be a ConsoleAppender using a PatternLayout. -log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender -log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout -log4j.appender.CONSOLE.layout.ConversionPattern=[%p] %m%n - -# LOGFILE is set to be a File appender using a PatternLayout. -log4j.appender.LOGFILE=org.apache.log4j.FileAppender -log4j.appender.LOGFILE.File=axis2.log -log4j.appender.LOGFILE.Append=true -log4j.appender.LOGFILE.layout=org.apache.log4j.PatternLayout -log4j.appender.LOGFILE.layout.ConversionPattern=%d [%t] %-5p %c %x - %m%n diff --git a/modules/samples/java_first_jaxws/src/webapp/WEB-INF/classes/log4j2.xml b/modules/samples/java_first_jaxws/src/webapp/WEB-INF/classes/log4j2.xml new file mode 100644 index 0000000..d2e94ac --- /dev/null +++ b/modules/samples/java_first_jaxws/src/webapp/WEB-INF/classes/log4j2.xml @@ -0,0 +1,44 @@ +<?xml version="1.0" encoding="UTF-8"?> +<Configuration status="debug" name="axis2" packages=""> + <Appenders> + <Console name="Console" target="SYSTEM_OUT"> + <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/> + </Console> + <RollingFile name="RollingFile" append="true" fileName="axis2.log" filePattern="axis2-%i.log.gz"> + <PatternLayout> + <Pattern>%d %p %c{1.} [%t] %m%n</Pattern> + </PatternLayout> + <Policies> + <OnStartupTriggeringPolicy/> + <SizeBasedTriggeringPolicy size="20 MB"/> + </Policies> + <DefaultRolloverStrategy max="10"> + <Delete basePath="${baseDir}" > + <IfFileName glob="*.log.*"> + <IfAny> + <IfLastModified age="5d" />- + </IfAny> + </IfFileName> + </Delete> + </DefaultRolloverStrategy> + </RollingFile> + </Appenders> + <Loggers> + <Logger name="org.apache" level="warn" additivity="false" > + <AppenderRef ref="RollingFile"/> + <AppenderRef ref="Console"/> + </Logger> + <Logger name="org.apache.axis2" level="debug" additivity="false" > + <AppenderRef ref="RollingFile"/> + <AppenderRef ref="Console"/> + </Logger> + <Logger name="org.springframework" level="warn" additivity="false" > + <AppenderRef ref="RollingFile"/> + <AppenderRef ref="Console"/> + </Logger> + <Root level="debug"> + <AppenderRef ref="Console"/> + <AppenderRef ref="RollingFile"/> + </Root> + </Loggers> +</Configuration> diff --git a/modules/samples/jaxws-samples/src/webapp/WEB-INF/classes/log4j.properties b/modules/samples/jaxws-samples/src/webapp/WEB-INF/classes/log4j.properties deleted file mode 100644 index ad3d8a7..0000000 --- a/modules/samples/jaxws-samples/src/webapp/WEB-INF/classes/log4j.properties +++ /dev/null @@ -1,40 +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. -# - - -# Set root category priority to INFO and its only appender to CONSOLE. -log4j.rootCategory=INFO, CONSOLE -#log4j.rootCategory=INFO, CONSOLE, LOGFILE - -# Set the enterprise logger priority to FATAL -log4j.logger.org.apache.axis2.enterprise=FATAL -log4j.logger.httpclient.wire.header=FATAL -log4j.logger.org.apache.commons.httpclient=FATAL - -# CONSOLE is set to be a ConsoleAppender using a PatternLayout. -log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender -log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout -log4j.appender.CONSOLE.layout.ConversionPattern=[%p] %m%n - -# LOGFILE is set to be a File appender using a PatternLayout. -log4j.appender.LOGFILE=org.apache.log4j.FileAppender -log4j.appender.LOGFILE.File=axis2.log -log4j.appender.LOGFILE.Append=true -log4j.appender.LOGFILE.layout=org.apache.log4j.PatternLayout -log4j.appender.LOGFILE.layout.ConversionPattern=%d [%t] %-5p %c %x - %m%n diff --git a/modules/samples/jaxws-samples/src/webapp/WEB-INF/classes/log4j2.xml b/modules/samples/jaxws-samples/src/webapp/WEB-INF/classes/log4j2.xml new file mode 100644 index 0000000..d2e94ac --- /dev/null +++ b/modules/samples/jaxws-samples/src/webapp/WEB-INF/classes/log4j2.xml @@ -0,0 +1,44 @@ +<?xml version="1.0" encoding="UTF-8"?> +<Configuration status="debug" name="axis2" packages=""> + <Appenders> + <Console name="Console" target="SYSTEM_OUT"> + <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/> + </Console> + <RollingFile name="RollingFile" append="true" fileName="axis2.log" filePattern="axis2-%i.log.gz"> + <PatternLayout> + <Pattern>%d %p %c{1.} [%t] %m%n</Pattern> + </PatternLayout> + <Policies> + <OnStartupTriggeringPolicy/> + <SizeBasedTriggeringPolicy size="20 MB"/> + </Policies> + <DefaultRolloverStrategy max="10"> + <Delete basePath="${baseDir}" > + <IfFileName glob="*.log.*"> + <IfAny> + <IfLastModified age="5d" />- + </IfAny> + </IfFileName> + </Delete> + </DefaultRolloverStrategy> + </RollingFile> + </Appenders> + <Loggers> + <Logger name="org.apache" level="warn" additivity="false" > + <AppenderRef ref="RollingFile"/> + <AppenderRef ref="Console"/> + </Logger> + <Logger name="org.apache.axis2" level="debug" additivity="false" > + <AppenderRef ref="RollingFile"/> + <AppenderRef ref="Console"/> + </Logger> + <Logger name="org.springframework" level="warn" additivity="false" > + <AppenderRef ref="RollingFile"/> + <AppenderRef ref="Console"/> + </Logger> + <Root level="debug"> + <AppenderRef ref="Console"/> + <AppenderRef ref="RollingFile"/> + </Root> + </Loggers> +</Configuration> diff --git a/modules/tool/axis2-ant-plugin/src/test/resources/log4j.properties b/modules/tool/axis2-ant-plugin/src/test/resources/log4j.properties deleted file mode 100644 index 79942cf..0000000 --- a/modules/tool/axis2-ant-plugin/src/test/resources/log4j.properties +++ /dev/null @@ -1,40 +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. -# - - -# Set root category priority to INFO and its only appender to CONSOLE. -log4j.rootCategory=INFO, CONSOLE -#log4j.rootCategory=INFO, CONSOLE, LOGFILE - -# Set the enterprise logger priority to FATAL -log4j.logger.org.apache.axis2.enterprise=FATAL -log4j.logger.httpclient.wire.header=FATAL -log4j.logger.org.apache.commons.httpclient=FATAL - -# CONSOLE is set to be a ConsoleAppender using a PatternLayout. -log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender -log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout -log4j.appender.CONSOLE.layout.ConversionPattern=%d %-5p %c - %m%n - -# LOGFILE is set to be a File appender using a PatternLayout. -log4j.appender.LOGFILE=org.apache.log4j.FileAppender -log4j.appender.LOGFILE.File=axis2.log -log4j.appender.LOGFILE.Append=true -log4j.appender.LOGFILE.layout=org.apache.log4j.PatternLayout -log4j.appender.LOGFILE.layout.ConversionPattern=%d [%t] %-5p %c %x - %m%n diff --git a/modules/tool/axis2-idea-plugin/pom.xml b/modules/tool/axis2-idea-plugin/pom.xml index 5d64a8a..b869026 100644 --- a/modules/tool/axis2-idea-plugin/pom.xml +++ b/modules/tool/axis2-idea-plugin/pom.xml @@ -117,8 +117,12 @@ <artifactId>woden-core</artifactId> </dependency> <dependency> - <groupId>log4j</groupId> - <artifactId>log4j</artifactId> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-api</artifactId> + </dependency> + <dependency> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-core</artifactId> </dependency> </dependencies> diff --git a/modules/tool/axis2-wsdl2code-maven-plugin/pom.xml b/modules/tool/axis2-wsdl2code-maven-plugin/pom.xml index 0ccb7f6..ea45f4d 100644 --- a/modules/tool/axis2-wsdl2code-maven-plugin/pom.xml +++ b/modules/tool/axis2-wsdl2code-maven-plugin/pom.xml @@ -173,8 +173,8 @@ </dependency> <dependency> <!-- JiBX uses log4j --> - <groupId>org.slf4j</groupId> - <artifactId>log4j-over-slf4j</artifactId> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-slf4j-impl</artifactId> </dependency> </dependencies> <build> diff --git a/modules/tool/axis2-wsdl2code-maven-plugin/src/test/resources/log4j.properties b/modules/tool/axis2-wsdl2code-maven-plugin/src/test/resources/log4j.properties deleted file mode 100644 index 79942cf..0000000 --- a/modules/tool/axis2-wsdl2code-maven-plugin/src/test/resources/log4j.properties +++ /dev/null @@ -1,40 +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. -# - - -# Set root category priority to INFO and its only appender to CONSOLE. -log4j.rootCategory=INFO, CONSOLE -#log4j.rootCategory=INFO, CONSOLE, LOGFILE - -# Set the enterprise logger priority to FATAL -log4j.logger.org.apache.axis2.enterprise=FATAL -log4j.logger.httpclient.wire.header=FATAL -log4j.logger.org.apache.commons.httpclient=FATAL - -# CONSOLE is set to be a ConsoleAppender using a PatternLayout. -log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender -log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout -log4j.appender.CONSOLE.layout.ConversionPattern=%d %-5p %c - %m%n - -# LOGFILE is set to be a File appender using a PatternLayout. -log4j.appender.LOGFILE=org.apache.log4j.FileAppender -log4j.appender.LOGFILE.File=axis2.log -log4j.appender.LOGFILE.Append=true -log4j.appender.LOGFILE.layout=org.apache.log4j.PatternLayout -log4j.appender.LOGFILE.layout.ConversionPattern=%d [%t] %-5p %c %x - %m%n diff --git a/modules/transport/jms/pom.xml b/modules/transport/jms/pom.xml index e040d2e..0909486 100644 --- a/modules/transport/jms/pom.xml +++ b/modules/transport/jms/pom.xml @@ -71,7 +71,7 @@ <systemProperties> <property> <name>log4j.configuration</name> - <value>file:../../log4j.properties</value> + <value>file:../../log4j2.xml</value> </property> </systemProperties> <argLine>${argLine} -javaagent:${aspectjweaver} -Xms64m -Xmx128m</argLine> diff --git a/modules/transport/jms/src/test/java/org/apache/axis2/transport/jms/LogAspect.java b/modules/transport/jms/src/test/java/org/apache/axis2/transport/jms/LogAspect.java index 611c132..024de24 100644 --- a/modules/transport/jms/src/test/java/org/apache/axis2/transport/jms/LogAspect.java +++ b/modules/transport/jms/src/test/java/org/apache/axis2/transport/jms/LogAspect.java @@ -29,7 +29,7 @@ import javax.jms.Message; import javax.jms.TextMessage; import org.apache.axis2.transport.jms.iowrappers.BytesMessageInputStream; -import org.apache.axis2.transport.testkit.util.LogManager; +import org.apache.axis2.transport.testkit.util.TestKitLogManager; import org.apache.commons.io.IOUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -44,7 +44,7 @@ public class LogAspect { " call(void javax.jms.TopicPublisher.publish(javax.jms.Message))) && args(message)") public void beforeSend(Message message) { try { - OutputStream out = LogManager.INSTANCE.createLog("jms"); + OutputStream out = TestKitLogManager.INSTANCE.createLog("jms"); try { PrintWriter pw = new PrintWriter(new OutputStreamWriter(out), false); pw.println("Type: " + message.getClass().getName()); diff --git a/modules/transport/mail/pom.xml b/modules/transport/mail/pom.xml index 20d6f95..dcaf228 100644 --- a/modules/transport/mail/pom.xml +++ b/modules/transport/mail/pom.xml @@ -92,7 +92,7 @@ <systemProperties> <property> <name>log4j.configuration</name> - <value>file:../../log4j.properties</value> + <value>file:../../log4j2.xml</value> </property> <property> <name>net.sourceforge.cobertura.datafile</name> diff --git a/modules/transport/mail/src/test/java/org/apache/axis2/transport/mail/GreenMailTestEnvironment.java b/modules/transport/mail/src/test/java/org/apache/axis2/transport/mail/GreenMailTestEnvironment.java index 1504cf0..b68ee78 100644 --- a/modules/transport/mail/src/test/java/org/apache/axis2/transport/mail/GreenMailTestEnvironment.java +++ b/modules/transport/mail/src/test/java/org/apache/axis2/transport/mail/GreenMailTestEnvironment.java @@ -33,7 +33,7 @@ import org.apache.axis2.transport.testkit.name.Name; import org.apache.axis2.transport.testkit.tests.Setup; import org.apache.axis2.transport.testkit.tests.TearDown; import org.apache.axis2.transport.testkit.tests.Transient; -import org.apache.axis2.transport.testkit.util.LogManager; +import org.apache.axis2.transport.testkit.util.TestKitLogManager; import org.apache.axis2.transport.testkit.util.PortAllocator; import org.apache.axis2.transport.testkit.util.ServerUtil; import org.apache.axis2.transport.testkit.util.tcpmon.Tunnel; @@ -51,7 +51,7 @@ public class GreenMailTestEnvironment extends MailTestEnvironment { private @Transient PortAllocator portAllocator; private @Transient ServerSetup smtpServerSetup; private @Transient ServerSetup storeServerSetup; - private @Transient LogManager logManager; + private @Transient TestKitLogManager logManager; private @Transient GreenMail greenMail; private @Transient Tunnel smtpTunnel; private int accountNumber; @@ -62,7 +62,7 @@ public class GreenMailTestEnvironment extends MailTestEnvironment { } @Setup @SuppressWarnings("unused") - private void setUp(LogManager logManager, PortAllocator portAllocator) throws Exception { + private void setUp(TestKitLogManager logManager, PortAllocator portAllocator) throws Exception { this.logManager = logManager; this.portAllocator = portAllocator; smtpServerSetup = new ServerSetup(portAllocator.allocatePort(), "127.0.0.1", ServerSetup.PROTOCOL_SMTP); diff --git a/modules/transport/mail/src/test/java/org/apache/axis2/transport/mail/LogAspect.java b/modules/transport/mail/src/test/java/org/apache/axis2/transport/mail/LogAspect.java index 3e5d72d..319d393 100644 --- a/modules/transport/mail/src/test/java/org/apache/axis2/transport/mail/LogAspect.java +++ b/modules/transport/mail/src/test/java/org/apache/axis2/transport/mail/LogAspect.java @@ -23,7 +23,7 @@ import java.io.OutputStream; import javax.mail.Message; -import org.apache.axis2.transport.testkit.util.LogManager; +import org.apache.axis2.transport.testkit.util.TestKitLogManager; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.aspectj.lang.annotation.Aspect; @@ -36,7 +36,7 @@ public class LogAspect { @Before("call(void javax.mail.Transport.send(javax.mail.Message)) && args(message)") public void beforeSend(Message message) { try { - OutputStream out = LogManager.INSTANCE.createLog("javamail"); + OutputStream out = TestKitLogManager.INSTANCE.createLog("javamail"); try { message.writeTo(out); } finally { diff --git a/modules/transport/tcp/pom.xml b/modules/transport/tcp/pom.xml index a86b5ce..d634405 100644 --- a/modules/transport/tcp/pom.xml +++ b/modules/transport/tcp/pom.xml @@ -50,7 +50,7 @@ <systemProperties> <property> <name>log4j.configuration</name> - <value>file:../../log4j.properties</value> + <value>file:../../log4j2.xml</value> </property> </systemProperties> </configuration> diff --git a/modules/transport/testkit/pom.xml b/modules/transport/testkit/pom.xml index 27af9cd..db0662d 100644 --- a/modules/transport/testkit/pom.xml +++ b/modules/transport/testkit/pom.xml @@ -83,6 +83,16 @@ <artifactId>jetty</artifactId> <version>5.1.10</version> </dependency> + <dependency> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-api</artifactId> + <version>2.14.0</version> + </dependency> + <dependency> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-core</artifactId> + <version>2.14.0</version> + </dependency> </dependencies> <profiles> diff --git a/modules/transport/testkit/src/main/java/org/apache/axis2/transport/testkit/ManagedTestSuite.java b/modules/transport/testkit/src/main/java/org/apache/axis2/transport/testkit/ManagedTestSuite.java index e352432..c7ad5c6 100644 --- a/modules/transport/testkit/src/main/java/org/apache/axis2/transport/testkit/ManagedTestSuite.java +++ b/modules/transport/testkit/src/main/java/org/apache/axis2/transport/testkit/ManagedTestSuite.java @@ -34,7 +34,7 @@ import org.apache.axis2.transport.testkit.filter.FilterExpressionParser; import org.apache.axis2.transport.testkit.tests.TestResourceSet; import org.apache.axis2.transport.testkit.tests.TestResourceSetTransition; import org.apache.axis2.transport.testkit.tests.ManagedTestCase; -import org.apache.axis2.transport.testkit.util.LogManager; +import org.apache.axis2.transport.testkit.util.TestKitLogManager; import org.apache.commons.lang.StringUtils; public class ManagedTestSuite extends TestSuite { @@ -89,7 +89,7 @@ public class ManagedTestSuite extends TestSuite { @Override public void run(TestResult result) { - LogManager logManager = LogManager.INSTANCE; + TestKitLogManager logManager = TestKitLogManager.INSTANCE; if (!reuseResources) { super.run(result); } else { diff --git a/modules/transport/testkit/src/main/java/org/apache/axis2/transport/testkit/axis2/LogAspect.java b/modules/transport/testkit/src/main/java/org/apache/axis2/transport/testkit/axis2/LogAspect.java index 06864b1..245adbb 100644 --- a/modules/transport/testkit/src/main/java/org/apache/axis2/transport/testkit/axis2/LogAspect.java +++ b/modules/transport/testkit/src/main/java/org/apache/axis2/transport/testkit/axis2/LogAspect.java @@ -26,7 +26,7 @@ import javax.activation.DataSource; import org.apache.axiom.om.OMOutputFormat; import org.apache.axis2.context.MessageContext; -import org.apache.axis2.transport.testkit.util.LogManager; +import org.apache.axis2.transport.testkit.util.TestKitLogManager; import org.apache.commons.io.IOUtils; import org.apache.commons.io.input.TeeInputStream; import org.apache.commons.io.output.TeeOutputStream; @@ -48,8 +48,8 @@ public class LogAspect { public void aroundWriteTo(ProceedingJoinPoint proceedingJoinPoint, MessageContext msgContext, OMOutputFormat format, OutputStream out, boolean preserve) throws Throwable { - if (LogManager.INSTANCE.isLoggingEnabled()) { - OutputStream log = LogManager.INSTANCE.createLog("formatter"); + if (TestKitLogManager.INSTANCE.isLoggingEnabled()) { + OutputStream log = TestKitLogManager.INSTANCE.createLog("formatter"); try { OutputStream tee = new TeeOutputStream(out, log); proceedingJoinPoint.proceed(new Object[] { msgContext, format, tee, preserve }); @@ -65,9 +65,9 @@ public class LogAspect { pointcut="call(javax.activation.DataSource org.apache.axis2.format.MessageFormatterEx.getDataSource(..))", returning="dataSource") public void afterGetDataSource(DataSource dataSource) { - if (LogManager.INSTANCE.isLoggingEnabled()) { + if (TestKitLogManager.INSTANCE.isLoggingEnabled()) { try { - OutputStream out = LogManager.INSTANCE.createLog("formatter"); + OutputStream out = TestKitLogManager.INSTANCE.createLog("formatter"); try { InputStream in = dataSource.getInputStream(); try { @@ -89,14 +89,14 @@ public class LogAspect { " && args(in, contentType, msgContext)") public Object aroundProcessDocument(ProceedingJoinPoint proceedingJoinPoint, InputStream in, String contentType, MessageContext msgContext) throws Throwable { - if (LogManager.INSTANCE.isLoggingEnabled()) { + if (TestKitLogManager.INSTANCE.isLoggingEnabled()) { InputStream tee; if (in == null) { tee = null; } else { - OutputStream log = LogManager.INSTANCE.createLog("builder"); + OutputStream log = TestKitLogManager.INSTANCE.createLog("builder"); // Note: We can't close the log right after the method execution because the - // message builder may use streaming. LogManager will take care of closing the + // message builder may use streaming. TestKitLogManager will take care of closing the // log for us if anything goes wrong. tee = new TeeInputStream(in, log, true); } diff --git a/modules/transport/testkit/src/main/java/org/apache/axis2/transport/testkit/axis2/endpoint/AxisTestEndpoint.java b/modules/transport/testkit/src/main/java/org/apache/axis2/transport/testkit/axis2/endpoint/AxisTestEndpoint.java index 825bd0e..3dc19cd 100644 --- a/modules/transport/testkit/src/main/java/org/apache/axis2/transport/testkit/axis2/endpoint/AxisTestEndpoint.java +++ b/modules/transport/testkit/src/main/java/org/apache/axis2/transport/testkit/axis2/endpoint/AxisTestEndpoint.java @@ -42,7 +42,7 @@ import org.apache.axis2.transport.testkit.name.Name; import org.apache.axis2.transport.testkit.tests.Setup; import org.apache.axis2.transport.testkit.tests.TearDown; import org.apache.axis2.transport.testkit.tests.Transient; -import org.apache.axis2.transport.testkit.util.LogManager; +import org.apache.axis2.transport.testkit.util.TestKitLogManager; /** * Base class for Axis2 based test endpoints. @@ -55,7 +55,7 @@ public abstract class AxisTestEndpoint { @Transient AxisService service; @Setup @SuppressWarnings("unused") - private void setUp(LogManager logManager, AxisTestEndpointContext context, Channel channel, + private void setUp(TestKitLogManager logManager, AxisTestEndpointContext context, Channel channel, AxisServiceConfigurator[] configurators) throws Exception { this.context = context; diff --git a/modules/transport/testkit/src/main/java/org/apache/axis2/transport/testkit/http/JettyByteArrayAsyncEndpoint.java b/modules/transport/testkit/src/main/java/org/apache/axis2/transport/testkit/http/JettyByteArrayAsyncEndpoint.java index 92ead40..b338e40 100644 --- a/modules/transport/testkit/src/main/java/org/apache/axis2/transport/testkit/http/JettyByteArrayAsyncEndpoint.java +++ b/modules/transport/testkit/src/main/java/org/apache/axis2/transport/testkit/http/JettyByteArrayAsyncEndpoint.java @@ -30,16 +30,16 @@ import org.apache.axiom.mime.ContentType; import org.apache.axis2.transport.testkit.message.IncomingMessage; import org.apache.axis2.transport.testkit.tests.Setup; import org.apache.axis2.transport.testkit.tests.Transient; -import org.apache.axis2.transport.testkit.util.LogManager; +import org.apache.axis2.transport.testkit.util.TestKitLogManager; import org.apache.commons.io.IOUtils; import org.mortbay.http.HttpException; import org.mortbay.http.HttpRequest; public class JettyByteArrayAsyncEndpoint extends JettyAsyncEndpoint<byte[]> { - private @Transient LogManager logManager; + private @Transient TestKitLogManager logManager; @Setup @SuppressWarnings("unused") - private void setUp(LogManager logManager) throws Exception { + private void setUp(TestKitLogManager logManager) throws Exception { this.logManager = logManager; } diff --git a/modules/transport/testkit/src/main/java/org/apache/axis2/transport/testkit/package-info.java b/modules/transport/testkit/src/main/java/org/apache/axis2/transport/testkit/package-info.java index 196b9ff..2752f54 100644 --- a/modules/transport/testkit/src/main/java/org/apache/axis2/transport/testkit/package-info.java +++ b/modules/transport/testkit/src/main/java/org/apache/axis2/transport/testkit/package-info.java @@ -253,10 +253,10 @@ * a maximum of information during the execution of each test case. * <p> * The collected information is written to a set of log files managed by - * {@link org.apache.axis2.transport.testkit.util.LogManager}. An instance is added automatically to + * {@link org.apache.axis2.transport.testkit.util.TestKitLogManager}. An instance is added automatically to * the resource set of every test case and other resources can acquire a reference through the dependency * injection mechanism described above. This is the recommended approach. Alternatively, the log manager - * can be used as a singleton through {@link org.apache.axis2.transport.testkit.util.LogManager#INSTANCE}. + * can be used as a singleton through {@link org.apache.axis2.transport.testkit.util.TestKitLogManager#INSTANCE}. * <p> * Logs files are written to subdirectories of <tt>target/testkit-logs</tt>. The directory structure has * a two level hierarchy identifying the test class (by its fully qualified name) and the test case @@ -290,4 +290,4 @@ * by different components involved in the test.</p></dd> * </dl> */ -package org.apache.axis2.transport.testkit; \ No newline at end of file +package org.apache.axis2.transport.testkit; diff --git a/modules/transport/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/ManagedTestCase.java b/modules/transport/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/ManagedTestCase.java index acb7d96..216b456 100644 --- a/modules/transport/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/ManagedTestCase.java +++ b/modules/transport/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/ManagedTestCase.java @@ -26,7 +26,7 @@ import junit.framework.TestCase; import org.apache.axis2.transport.testkit.name.Key; import org.apache.axis2.transport.testkit.name.NameUtils; -import org.apache.axis2.transport.testkit.util.LogManager; +import org.apache.axis2.transport.testkit.util.TestKitLogManager; @Key("test") public abstract class ManagedTestCase extends TestCase { @@ -40,7 +40,7 @@ public abstract class ManagedTestCase extends TestCase { public ManagedTestCase(Object... resources) { resourceSet.addResources(resources); - addResource(LogManager.INSTANCE); + addResource(TestKitLogManager.INSTANCE); } protected void addResource(Object resource) { @@ -108,7 +108,7 @@ public abstract class ManagedTestCase extends TestCase { @Override protected void setUp() throws Exception { if (!managed) { - LogManager.INSTANCE.setTestCase(this); + TestKitLogManager.INSTANCE.setTestCase(this); resourceSet.setUp(); } } @@ -117,7 +117,7 @@ public abstract class ManagedTestCase extends TestCase { protected void tearDown() throws Exception { if (!managed) { resourceSet.tearDown(); - LogManager.INSTANCE.setTestCase(null); + TestKitLogManager.INSTANCE.setTestCase(null); } } @@ -125,4 +125,4 @@ public abstract class ManagedTestCase extends TestCase { public String toString() { return getName() + "(" + testClass.getName() + ")"; } -} \ No newline at end of file +} diff --git a/modules/transport/testkit/src/main/java/org/apache/axis2/transport/testkit/util/LogManager.java b/modules/transport/testkit/src/main/java/org/apache/axis2/transport/testkit/util/TestKitLogManager.java similarity index 60% rename from modules/transport/testkit/src/main/java/org/apache/axis2/transport/testkit/util/LogManager.java rename to modules/transport/testkit/src/main/java/org/apache/axis2/transport/testkit/util/TestKitLogManager.java index 1017e95..365f731 100644 --- a/modules/transport/testkit/src/main/java/org/apache/axis2/transport/testkit/util/LogManager.java +++ b/modules/transport/testkit/src/main/java/org/apache/axis2/transport/testkit/util/TestKitLogManager.java @@ -21,43 +21,47 @@ package org.apache.axis2.transport.testkit.util; import java.io.File; import java.io.FileOutputStream; +import java.io.StringWriter; import java.io.IOException; import java.io.OutputStream; +import java.nio.charset.StandardCharsets; import java.util.LinkedList; import java.util.List; import org.apache.axis2.transport.testkit.tests.ManagedTestCase; import org.apache.commons.io.IOUtils; import org.apache.commons.lang.StringUtils; -import org.apache.log4j.Logger; -import org.apache.log4j.TTCCLayout; -import org.apache.log4j.WriterAppender; -public class LogManager { - public static final LogManager INSTANCE = new LogManager(); +import org.apache.logging.log4j.core.Appender; +import org.apache.logging.log4j.core.appender.WriterAppender; +import org.apache.logging.log4j.core.config.Configuration; +import org.apache.logging.log4j.core.Logger; +import org.apache.logging.log4j.core.LoggerContext; +import org.apache.logging.log4j.core.layout.PatternLayout; +import org.apache.logging.log4j.LogManager; + +public class TestKitLogManager { + public static final TestKitLogManager INSTANCE = new TestKitLogManager(); private final File logDir; private File testCaseDir; - private WriterAppender appender; + private Appender appender; private int sequence; private List<OutputStream> logs; + + private static final Logger logger = + (Logger) LogManager.getLogger(TestKitLogManager.class); + - private LogManager() { + private TestKitLogManager() { logDir = new File("target" + File.separator + "testkit-logs"); } public void setTestCase(ManagedTestCase testCase) throws IOException { if (appender != null) { - Logger.getRootLogger().removeAppender(appender); - appender.close(); + ((Logger) LogManager.getRootLogger()).removeAppender(appender); appender = null; } - if (logs != null) { - for (OutputStream log : logs) { - IOUtils.closeQuietly(log); - } - logs = null; - } if (testCase == null) { testCaseDir = null; } else { @@ -65,19 +69,32 @@ public class LogManager { testCaseDir = new File(testSuiteDir, testCase.getId()); logs = new LinkedList<OutputStream>(); sequence = 1; - appender = new WriterAppender(new TTCCLayout(), createLog("debug")); - Logger.getRootLogger().addAppender(appender); + + LoggerContext ctx = (LoggerContext) LogManager.getContext(false); + Configuration config = ctx.getConfiguration(); + + StringWriter output = new StringWriter(); + appender = WriterAppender.newBuilder().setTarget(output).setName("debug").setLayout(PatternLayout.newBuilder().withPattern(PatternLayout.TTCC_CONVERSION_PATTERN).build()).setConfiguration(config).build(); + + if (appender != null) { + if (!appender.isStarted()) { + appender.start(); + } + config.addAppender(appender); + } } } public synchronized boolean isLoggingEnabled() { return testCaseDir != null; } - + public synchronized OutputStream createLog(String name) throws IOException { testCaseDir.mkdirs(); - OutputStream log = new FileOutputStream(new File(testCaseDir, StringUtils.leftPad(String.valueOf(sequence++), 2, '0') + "-" + name + ".log")); + OutputStream log = new FileOutputStream(new File(testCaseDir, StringUtils.leftPad(String.valueOf(sequence++), +2, '0') + "-" + name + ".log")); logs.add(log); return log; } + } diff --git a/modules/webapp/pom.xml b/modules/webapp/pom.xml index a34bd3a..0536371 100644 --- a/modules/webapp/pom.xml +++ b/modules/webapp/pom.xml @@ -41,8 +41,12 @@ <version>${project.version}</version> </dependency> <dependency> - <groupId>log4j</groupId> - <artifactId>log4j</artifactId> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-api</artifactId> + </dependency> + <dependency> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-core</artifactId> </dependency> <dependency> <groupId>org.apache.axis2</groupId> diff --git a/pom.xml b/pom.xml index 71d3366..f4319f8 100644 --- a/pom.xml +++ b/pom.xml @@ -534,7 +534,7 @@ <jaxbcore.version>2.3.0.1</jaxbcore.version> <jettison.version>1.3.8</jettison.version> <jibx.version>1.3.1</jibx.version> - <log4j.version>1.2.15</log4j.version> + <log4j2.version>2.14.0</log4j2.version> <maven.archiver.version>3.0.2</maven.archiver.version> <maven.version>3.3.9</maven.version> <maven.plugin.descriptor.version>2.0.7</maven.plugin.descriptor.version> @@ -714,6 +714,12 @@ <groupId>org.jibx</groupId> <artifactId>jibx-bind</artifactId> <version>${jibx.version}</version> + <exclusions> + <exclusion> + <groupId>log4j</groupId> + <artifactId>log4j</artifactId> + </exclusion> + </exclusions> </dependency> <dependency> <groupId>org.jibx</groupId> @@ -818,11 +824,10 @@ <version>${slf4j.version}</version> </dependency> <dependency> - <groupId>org.slf4j</groupId> - <artifactId>log4j-over-slf4j</artifactId> - <version>${slf4j.version}</version> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-slf4j-impl</artifactId> + <version>${log4j2.version}</version> </dependency> - <dependency> <groupId>com.sun.mail</groupId> <artifactId>javax.mail</artifactId> @@ -968,9 +973,19 @@ <version>${plexus.classworlds.version}</version> </dependency> <dependency> - <groupId>log4j</groupId> - <artifactId>log4j</artifactId> - <version>${log4j.version}</version> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-jcl</artifactId> + <version>${log4j2.version}</version> + </dependency> + <dependency> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-api</artifactId> + <version>${log4j2.version}</version> + </dependency> + <dependency> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-core</artifactId> + <version>${log4j2.version}</version> <exclusions> <exclusion> <groupId>javax.mail</groupId> diff --git a/src/site/xdoc/docs/modules.xml b/src/site/xdoc/docs/modules.xml index 9837e48..ea7f872 100644 --- a/src/site/xdoc/docs/modules.xml +++ b/src/site/xdoc/docs/modules.xml @@ -376,11 +376,6 @@ Codegeneration</a>', and copy the "logging.mar" file to the "modules" directory.</p> <p>Then run 'ant run.client.servicewithmodule' from <strong>axis2home/samples/userguide directory</strong></p> -<p>Note: To see the logs, the user needs to modify the -"log4j.properties" to log INFO. The property file is located in -"<strong>webapps/axis2/WEB-INF/classes</strong>" of your servlet -container. Change the line "log4j.rootCategory= ERROR, LOGFILE" to -"log4j.rootCategory=INFO, ERROR, LOGFILE".</p> <p><font size="2"><b>Note (on samples):</b></font> All the samples mentioned in the user's guide are located at the <b>"samples\userguide\src"</b> directory of the binary diff --git a/src/site/xdoc/docs/userguide.xml b/src/site/xdoc/docs/userguide.xml index 459164d..551d92b 100644 --- a/src/site/xdoc/docs/userguide.xml +++ b/src/site/xdoc/docs/userguide.xml @@ -305,7 +305,7 @@ WEB-INF directory represents the actual Axis2 application, including all the *.jar files, any included modules, and even the deployed services themselves.</p> <p>The classes directory holds any class or property files that are -needed by Axis2 itself, such as log4j.properties. Any actual +needed by Axis2 itself, such as log4j2.xml. Any actual services to be handled by the system reside in the services directory in the form of an axis archive, or *.aar file. This file contains any classes related to the service, as well as the