INTSAMPLES-150: Switch to Log4j2
JIRA: https://jira.spring.io/browse/INTSAMPLES-150
This commit is contained in:
committed by
Artem Bilan
parent
68377fedd1
commit
e37904128e
@@ -31,4 +31,4 @@ public class EchoService {
|
||||
return "echo:" + input;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,4 +23,4 @@ public interface SimpleGateway {
|
||||
|
||||
public String send(String text);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
|
||||
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
|
||||
|
||||
<!-- Appenders -->
|
||||
<appender name="console" class="org.apache.log4j.ConsoleAppender">
|
||||
<param name="Target" value="System.out" />
|
||||
<layout class="org.apache.log4j.PatternLayout">
|
||||
<param name="ConversionPattern" value="%d{HH:mm:ss.SSS} %-5p [%t][%c] %m%n" />
|
||||
</layout>
|
||||
</appender>
|
||||
|
||||
<!-- Loggers -->
|
||||
<logger name="org.springframework">
|
||||
<level value="warn" />
|
||||
</logger>
|
||||
|
||||
<logger name="org.springframework.integration">
|
||||
<level value="warn" />
|
||||
</logger>
|
||||
|
||||
<logger name="org.springframework.integration.samples">
|
||||
<level value="debug" />
|
||||
</logger>
|
||||
|
||||
<!-- Root Logger -->
|
||||
<root>
|
||||
<priority value="warn" />
|
||||
<appender-ref ref="console" />
|
||||
</root>
|
||||
|
||||
</log4j:configuration>
|
||||
16
basic/tcp-client-server/src/main/resources/log4j2.xml
Normal file
16
basic/tcp-client-server/src/main/resources/log4j2.xml
Normal file
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Configuration status="WARN">
|
||||
<Appenders>
|
||||
<Console name="Console" target="SYSTEM_OUT">
|
||||
<PatternLayout pattern="%d{HH:mm:ss.SSS} %-5p [%t][%c] %m%n" />
|
||||
</Console>
|
||||
</Appenders>
|
||||
<Loggers>
|
||||
<Root level="info">
|
||||
<AppenderRef ref="Console" />
|
||||
</Root>
|
||||
<Logger name="org.springframework" level="warn" />
|
||||
<Logger name="org.springframework.integration" level="warn" />
|
||||
<Logger name="org.springframework.integration.samples" level="debug" />
|
||||
</Loggers>
|
||||
</Configuration>
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2017 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.
|
||||
@@ -26,20 +26,22 @@ import java.io.OutputStreamWriter;
|
||||
import java.io.Writer;
|
||||
import java.net.Socket;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.messaging.SubscribableChannel;
|
||||
import org.springframework.integration.handler.AbstractReplyProducingMessageHandler;
|
||||
import org.springframework.integration.ip.tcp.connection.AbstractServerConnectionFactory;
|
||||
import org.springframework.integration.ip.util.TestingUtilities;
|
||||
import org.springframework.integration.samples.tcpclientserver.support.CustomTestContextLoader;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.messaging.SubscribableChannel;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
@@ -52,15 +54,16 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
*
|
||||
* @author Christian Posta
|
||||
* @author Gunnar Hillert
|
||||
* @author Gary Russell
|
||||
*
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(loader=CustomTestContextLoader.class,
|
||||
locations = {"/META-INF/spring/integration/tcpServerCustomSerialize-context.xml"})
|
||||
@ContextConfiguration(loader = CustomTestContextLoader.class, locations = {
|
||||
"/META-INF/spring/integration/tcpServerCustomSerialize-context.xml" })
|
||||
@DirtiesContext
|
||||
public class TcpServerCustomSerializerTest {
|
||||
|
||||
private static final Logger LOGGER = Logger.getLogger(TcpServerCustomSerializerTest.class);
|
||||
private static final Log LOGGER = LogFactory.getLog(TcpServerCustomSerializerTest.class);
|
||||
|
||||
@Autowired
|
||||
@Qualifier("incomingServerChannel")
|
||||
@@ -84,7 +87,7 @@ public class TcpServerCustomSerializerTest {
|
||||
// the reason we use a listener here is so we can assert truths on the
|
||||
// message and/or payload
|
||||
SubscribableChannel channel = (SubscribableChannel) incomingServerChannel;
|
||||
channel.subscribe(new AbstractReplyProducingMessageHandler(){
|
||||
channel.subscribe(new AbstractReplyProducingMessageHandler() {
|
||||
|
||||
@Override
|
||||
protected Object handleRequestMessage(Message<?> requestMessage) {
|
||||
@@ -124,16 +127,19 @@ public class TcpServerCustomSerializerTest {
|
||||
String response = str.toString();
|
||||
assertEquals(sourceMessage, response);
|
||||
|
||||
} catch (IOException e) {
|
||||
}
|
||||
catch (IOException e) {
|
||||
LOGGER.error(e.getMessage(), e);
|
||||
fail(String.format("Test (port: %s) ended with an exception: %s", availableServerSocket, e.getMessage()));
|
||||
} finally {
|
||||
}
|
||||
finally {
|
||||
try {
|
||||
socket.close();
|
||||
out.close();
|
||||
in.close();
|
||||
|
||||
} catch (Exception e) {
|
||||
}
|
||||
catch (Exception e) {
|
||||
// swallow exception
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2017 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.
|
||||
@@ -18,7 +18,9 @@ package org.springframework.integration.samples.tcpclientserver.support;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.context.support.GenericApplicationContext;
|
||||
import org.springframework.core.env.MapPropertySource;
|
||||
import org.springframework.integration.test.util.SocketUtils;
|
||||
@@ -27,10 +29,11 @@ import org.springframework.test.context.support.GenericXmlContextLoader;
|
||||
|
||||
/**
|
||||
* @author Gunnar Hillert
|
||||
* @author Gary Russell
|
||||
*/
|
||||
public class CustomTestContextLoader extends GenericXmlContextLoader {
|
||||
|
||||
private static final Logger LOGGER = Logger.getLogger(CustomTestContextLoader.class);
|
||||
private static final Log LOGGER = LogFactory.getLog(CustomTestContextLoader.class);
|
||||
|
||||
@Override
|
||||
protected void loadBeanDefinitions(GenericApplicationContext context,
|
||||
|
||||
Reference in New Issue
Block a user