Skip to content

INT-4376: Upgage to Log4J 2 #2321

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ subprojects { subproject ->
junitVersion = '4.12'
jythonVersion = '2.5.3'
kryoShadedVersion = '3.0.3'
log4jVersion = '1.2.17'
log4jVersion = '2.10.0'
mockitoVersion = '2.11.0'
mysqlVersion = '6.0.6'
pahoMqttClientVersion = '1.2.0'
Expand All @@ -127,7 +127,6 @@ subprojects { subproject ->
reactorVersion = '3.1.2.RELEASE'
romeToolsVersion = '1.8.0'
servletApiVersion = '4.0.0'
slf4jVersion = "1.7.25"
smackVersion = '4.2.2'
springAmqpVersion = project.hasProperty('springAmqpVersion') ? project.springAmqpVersion : '2.0.1.RELEASE'
springDataJpaVersion = '2.0.2.RELEASE'
Expand Down Expand Up @@ -160,7 +159,8 @@ subprojects { subproject ->
testCompile project(":spring-integration-test-support")
}

testCompile "org.slf4j:slf4j-log4j12:$slf4jVersion"
testRuntime "org.apache.logging.log4j:log4j-slf4j-impl:$log4jVersion"
testRuntime "org.apache.logging.log4j:log4j-jcl:$log4jVersion"
}

// enable all compiler warnings; individual projects may customize further
Expand Down Expand Up @@ -275,7 +275,8 @@ project('spring-integration-test-support') {
compile "org.springframework:spring-context:$springVersion"
compile "org.springframework:spring-messaging:$springVersion"
compile "org.springframework:spring-test:$springVersion"
compile ("log4j:log4j:$log4jVersion", optional)
compile ("org.apache.logging.log4j:log4j-core:$log4jVersion" , optional)
compile ('log4j:log4j:1.2.17', optional)
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016-2017 the original author or authors.
* Copyright 2016-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -35,7 +35,6 @@
import java.util.concurrent.TimeUnit;

import org.apache.commons.logging.Log;
import org.apache.log4j.Level;
import org.junit.AfterClass;
import org.junit.ClassRule;
import org.junit.Rule;
Expand All @@ -59,7 +58,7 @@
import org.springframework.integration.channel.DirectChannel;
import org.springframework.integration.channel.QueueChannel;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.integration.test.rule.Log4jLevelAdjuster;
import org.springframework.integration.test.rule.Log4j2LevelAdjuster;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessagingException;
import org.springframework.messaging.support.ErrorMessage;
Expand All @@ -78,8 +77,10 @@ public class AsyncAmqpGatewayTests {
public static BrokerRunning brokerRunning = BrokerRunning.isRunningWithEmptyQueues("asyncQ1", "asyncRQ1");

@Rule
public Log4jLevelAdjuster adjuster = new Log4jLevelAdjuster(Level.TRACE, "org.springframework.integration",
"org.springframework.amqp");
public Log4j2LevelAdjuster adjuster =
Log4j2LevelAdjuster.trace()
.categories("org.springframework.integration",
"org.springframework.amqp");

@AfterClass
public static void tearDown() {
Expand Down
10 changes: 0 additions & 10 deletions spring-integration-amqp/src/test/resources/log4j.properties

This file was deleted.

17 changes: 17 additions & 0 deletions spring-integration-amqp/src/test/resources/log4j2-test.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN">
<Appenders>
<Console name="STDOUT" target="SYSTEM_OUT">
<PatternLayout pattern="%d %p [%t] [%c] - %m%n" />
</Console>
</Appenders>
<Loggers>
<Logger name="test" level="debug"/>
<Logger name="org.springframework" level="warn"/>
<Logger name="org.springframework.amqp" level="warn"/>
<Logger name="org.springframework.integration.amqp" level="warn"/>
<Root level="warn">
<AppenderRef ref="STDOUT" />
</Root>
</Loggers>
</Configuration>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -25,60 +25,27 @@
import java.util.concurrent.TimeUnit;

import org.junit.AfterClass;
import org.junit.Assume;
import org.junit.Rule;
import org.junit.ClassRule;
import org.junit.Test;
import org.junit.rules.TestWatcher;
import org.junit.runner.Description;
import org.junit.runners.model.Statement;

import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.integration.channel.QueueChannel;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.integration.test.support.LongRunningIntegrationTest;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;

/**
* @author Oleg Zhurakousky
* @author Gary Russell
* @author Artem Bilan
*
*/
public class AggregatorWithCustomReleaseStrategyTests {

@Rule
public TestWatcher longTests = new TestWatcher() {

private static final String RUN_LONG_PROP = "RUN_LONG_INTEGRATION_TESTS";

private boolean shouldRun;

{
for (String value: new String[]{System.getenv(RUN_LONG_PROP), System.getProperty(RUN_LONG_PROP)}) {
if ("true".equalsIgnoreCase(value)) {
this.shouldRun = true;
break;
}
}
}

@Override
public Statement apply(Statement base, Description description) {
if (!this.shouldRun) {
return new Statement() {

@Override
public void evaluate() throws Throwable {
Assume.assumeTrue(false);
}
};
}
else {
return super.apply(base, description);
}
}

};
@ClassRule
public static LongRunningIntegrationTest longTests = new LongRunningIntegrationTest();

private static ExecutorService executor = Executors.newCachedThreadPool();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -40,6 +40,7 @@
* @author Mark Fisher
* @author Artem Bilan
* @author Gary Russell
*
* @since 2.1
*/
@ContextConfiguration
Expand All @@ -56,7 +57,8 @@ public class LoggingChannelAdapterParserTests {
@Test
public void verifyConfig() {
LoggingHandler loggingHandler = TestUtils.getPropertyValue(loggerConsumer, "handler", LoggingHandler.class);
assertEquals("org.springframework.integration.test.logger", TestUtils.getPropertyValue(loggingHandler, "messageLogger.name"));
assertEquals("org.springframework.integration.test.logger",
TestUtils.getPropertyValue(loggingHandler, "messageLogger.logger.name"));
assertEquals(1, TestUtils.getPropertyValue(loggingHandler, "order"));
assertEquals("WARN", TestUtils.getPropertyValue(loggingHandler, "level").toString());
assertEquals("#root", TestUtils.getPropertyValue(loggingHandler, "expression.expression"));
Expand All @@ -65,7 +67,8 @@ public void verifyConfig() {
@Test
public void verifyExpressionAndOtherDefaultConfig() {
LoggingHandler loggingHandler = TestUtils.getPropertyValue(loggerWithExpression, "handler", LoggingHandler.class);
assertEquals("org.springframework.integration.handler.LoggingHandler", TestUtils.getPropertyValue(loggingHandler, "messageLogger.name"));
assertEquals("org.springframework.integration.handler.LoggingHandler",
TestUtils.getPropertyValue(loggingHandler, "messageLogger.logger.name"));
assertEquals(Ordered.LOWEST_PRECEDENCE, TestUtils.getPropertyValue(loggingHandler, "order"));
assertEquals("INFO", TestUtils.getPropertyValue(loggingHandler, "level").toString());
assertEquals("payload.foo", TestUtils.getPropertyValue(loggingHandler, "expression.expression"));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2014-2017 the original author or authors.
* Copyright 2014-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -42,7 +42,6 @@
import org.aopalliance.aop.Advice;
import org.aopalliance.intercept.Joinpoint;
import org.aopalliance.intercept.MethodInterceptor;
import org.apache.log4j.Level;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
Expand All @@ -67,7 +66,7 @@
import org.springframework.integration.core.MessageSource;
import org.springframework.integration.scheduling.PollSkipAdvice;
import org.springframework.integration.scheduling.SimplePollSkipStrategy;
import org.springframework.integration.test.rule.Log4jLevelAdjuster;
import org.springframework.integration.test.rule.Log4j2LevelAdjuster;
import org.springframework.integration.test.util.OnlyOnceTrigger;
import org.springframework.integration.test.util.TestUtils;
import org.springframework.integration.util.CompoundTrigger;
Expand All @@ -85,6 +84,8 @@

/**
* @author Gary Russell
* @author Artem Bilan
*
* @since 4.1
*
*/
Expand All @@ -94,7 +95,7 @@
public class PollerAdviceTests {

@Rule
public Log4jLevelAdjuster adjuster = new Log4jLevelAdjuster(Level.TRACE, "org.springframework.integration");
public Log4j2LevelAdjuster adjuster = Log4j2LevelAdjuster.trace();

@Autowired
private MessageChannel control;
Expand Down
Loading