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-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.
@@ -18,89 +18,83 @@ package org.springframework.integration.samples.storedprocedure;
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.model.CoffeeBeverage;
import org.springframework.integration.service.CoffeeService;
/**
* Starts the Spring Context and will initialize the Spring Integration routes.
*
* @author Gunnar Hillert
* @author Gary Russell
* @since 2.1
*
*/
public final class Main {
private static final Logger LOGGER = Logger.getLogger(Main.class);
private static final Log LOGGER = LogFactory.getLog(Main.class);
private static final String LINE = "\n=========================================================";
private static final String NEWLINE = "\n ";
private static final String LINE = "\n=========================================================";
private Main() { }
private static final String NEWLINE = "\n ";
/**
* Load the Spring Integration Application Context
*
* @param args - command line arguments
*/
public static void main(final String... args) {
private Main() {
}
LOGGER.info(LINE
+ LINE
+ "\n Welcome to Spring Integration Coffee Database! "
+ NEWLINE
+ "\n For more information please visit: "
+ "\n http://www.springsource.org/spring-integration "
+ NEWLINE
+ LINE );
/**
* Load the Spring Integration Application Context
*
* @param args - command line arguments
*/
public static void main(final String... args) {
final AbstractApplicationContext context =
new ClassPathXmlApplicationContext("classpath:META-INF/spring/integration/*-context.xml");
LOGGER.info(LINE + LINE + "\n Welcome to Spring Integration Coffee Database! " + NEWLINE
+ "\n For more information please visit: "
+ "\n http://www.springsource.org/spring-integration " + NEWLINE + LINE);
context.registerShutdownHook();
final AbstractApplicationContext context = new ClassPathXmlApplicationContext(
"classpath:META-INF/spring/integration/*-context.xml");
final Scanner scanner = new Scanner(System.in);
context.registerShutdownHook();
final CoffeeService service = context.getBean(CoffeeService.class);
final Scanner scanner = new Scanner(System.in);
LOGGER.info(LINE
+ NEWLINE
+ "\n Please press 'q + Enter' to quit the application. "
+ NEWLINE
+ LINE);
final CoffeeService service = context.getBean(CoffeeService.class);
System.out.print("Please enter 'list' and press <enter> to get a list of coffees.");
System.out.print("Enter a coffee id, e.g. '1' and press <enter> to get a description.\n\n");
LOGGER.info(LINE + NEWLINE + "\n Please press 'q + Enter' to quit the application. " + NEWLINE + LINE);
while (!scanner.hasNext("q")) {
System.out.print("Please enter 'list' and press <enter> to get a list of coffees.");
System.out.print("Enter a coffee id, e.g. '1' and press <enter> to get a description.\n\n");
String input = scanner.nextLine();
while (!scanner.hasNext("q")) {
if ("list".equalsIgnoreCase(input)) {
List<CoffeeBeverage> coffeeBeverages = service.findAllCoffeeBeverages();
String input = scanner.nextLine();
for (CoffeeBeverage coffeeBeverage : coffeeBeverages) {
System.out.println(String.format("%s - %s", coffeeBeverage.getId(),
coffeeBeverage.getName()));
}
if ("list".equalsIgnoreCase(input)) {
List<CoffeeBeverage> coffeeBeverages = service.findAllCoffeeBeverages();
} else {
System.out.println("Retrieving coffee information...");
String coffeeDescription = service.findCoffeeBeverage(Integer.valueOf(input));
for (CoffeeBeverage coffeeBeverage : coffeeBeverages) {
System.out.println(String.format("%s - %s", coffeeBeverage.getId(), coffeeBeverage.getName()));
}
System.out.println(String.format("Searched for '%s' - Found: '%s'.", input, coffeeDescription));
System.out.print("To try again, please enter another coffee beaverage and press <enter>:\n\n");
}
}
else {
System.out.println("Retrieving coffee information...");
String coffeeDescription = service.findCoffeeBeverage(Integer.valueOf(input));
}
System.out.println(String.format("Searched for '%s' - Found: '%s'.", input, coffeeDescription));
System.out.print("To try again, please enter another coffee beaverage and press <enter>:\n\n");
}
LOGGER.info("Exiting application...bye.");
}
System.exit(0);
LOGGER.info("Exiting application...bye.");
scanner.close();
context.close();
}
}
}

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>