INTSAMPLES-150: Switch to Log4j2

JIRA: https://jira.spring.io/browse/INTSAMPLES-150
This commit is contained in:
Gary Russell
2017-08-28 16:24:00 -04:00
committed by Artem Bilan
parent 68377fedd1
commit e37904128e
240 changed files with 5202 additions and 2533 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2010 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.
@@ -21,7 +21,9 @@ import java.util.Date;
import java.util.List;
import java.util.Scanner;
import org.apache.log4j.Logger;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.integration.samples.jdbc.domain.Gender;
@@ -34,12 +36,13 @@ import org.springframework.integration.samples.jdbc.service.PersonService;
*
* @author Gunnar Hillert
* @author Amol Nayak
* @author Gary Russell
* @version 1.0
*
*/
public final class Main {
private static final Logger LOGGER = Logger.getLogger(Main.class);
private static final Log LOGGER = LogFactory.getLog(Main.class);
private Main() { }
@@ -101,7 +104,7 @@ public final class Main {
LOGGER.info("Exiting application...bye.");
System.exit(0);
context.close();
}
@@ -139,8 +142,9 @@ public final class Main {
System.out.println("Created person record with id: " + person.getPersonId());
System.out.print("Do you want to create another person? (y/n)");
String choice = scanner.nextLine();
if(!"y".equalsIgnoreCase(choice))
if(!"y".equalsIgnoreCase(choice)) {
break;
}
}
}
/**
@@ -165,8 +169,9 @@ public final class Main {
}
System.out.print("Do you want to find another person? (y/n)");
String choice = scanner.nextLine();
if(!"y".equalsIgnoreCase(choice))
if(!"y".equalsIgnoreCase(choice)) {
break;
}
}
}

View File

@@ -1,28 +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.integration">
<level value="warn" />
</logger>
<logger name="org.springframework.integration.samples">
<level value="info" />
</logger>
<!-- Root Logger -->
<root>
<priority value="warn" />
<appender-ref ref="console" />
</root>
</log4j:configuration>

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

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2011 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.
@@ -17,10 +17,11 @@ package org.springframework.integration.samples.jdbc;
import java.util.Calendar;
import org.apache.log4j.Logger;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.junit.Assert;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.integration.samples.jdbc.domain.Gender;
import org.springframework.integration.samples.jdbc.domain.Person;
@@ -29,16 +30,17 @@ import org.springframework.integration.samples.jdbc.service.PersonService;
/**
* The test class for jdbc outbound gateway
* @author Amol Nayak
* @author Gary Russell
*
*/
public class OutboundGatewayTest {
private Logger logger = Logger.getLogger(OutboundGatewayTest.class);
private final Log logger = LogFactory.getLog(OutboundGatewayTest.class);
@Test
public void insertPersonRecord() {
ApplicationContext context
= new ClassPathXmlApplicationContext("/META-INF/spring/integration/spring-integration-context.xml");
public void insertPersonRecord() {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
"/META-INF/spring/integration/spring-integration-context.xml");
PersonService service = context.getBean(PersonService.class);
logger.info("Creating person Instance");
Person person = new Person();
@@ -50,6 +52,7 @@ public class OutboundGatewayTest {
person = service.createPerson(person);
Assert.assertNotNull("Expected a non null instance of Person, got null", person);
logger.info("\n\tGenerated person with id: " + person.getPersonId() + ", with name: " + person.getName());
context.close();
}
}