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
@@ -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.
|
||||
@@ -17,7 +17,9 @@ package org.springframework.integration.samples.poller;
|
||||
|
||||
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;
|
||||
|
||||
@@ -25,75 +27,79 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
* Starts the Spring Context and will initialize the Spring Integration routes.
|
||||
*
|
||||
* @author Gunnar Hillert
|
||||
* @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() { }
|
||||
private Main() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the Spring Integration Application Context
|
||||
*
|
||||
* @param args - command line arguments
|
||||
*/
|
||||
public static void main(final String... args) {
|
||||
/**
|
||||
* Load the Spring Integration Application Context
|
||||
*
|
||||
* @param args - command line arguments
|
||||
*/
|
||||
public static void main(final String... args) {
|
||||
|
||||
LOGGER.info("\n=========================================================="
|
||||
+ "\n "
|
||||
+ "\n Welcome to the Spring Integration Dynamic Poller Sample! "
|
||||
+ "\n "
|
||||
+ "\n For more information please visit: "
|
||||
+ "\n http://www.springsource.org/spring-integration "
|
||||
+ "\n "
|
||||
+ "\n==========================================================" );
|
||||
LOGGER.info("\n=========================================================="
|
||||
+ "\n "
|
||||
+ "\n Welcome to the Spring Integration Dynamic Poller Sample! "
|
||||
+ "\n "
|
||||
+ "\n For more information please visit: "
|
||||
+ "\n http://www.springsource.org/spring-integration "
|
||||
+ "\n "
|
||||
+ "\n==========================================================");
|
||||
|
||||
final AbstractApplicationContext context =
|
||||
new ClassPathXmlApplicationContext("classpath:META-INF/spring/integration/*-context.xml");
|
||||
final AbstractApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
"classpath:META-INF/spring/integration/*-context.xml");
|
||||
|
||||
context.registerShutdownHook();
|
||||
context.registerShutdownHook();
|
||||
|
||||
final Scanner scanner = new Scanner(System.in);
|
||||
final Scanner scanner = new Scanner(System.in);
|
||||
|
||||
final DynamicPeriodicTrigger trigger = context.getBean(DynamicPeriodicTrigger.class);
|
||||
final DynamicPeriodicTrigger trigger = context.getBean(DynamicPeriodicTrigger.class);
|
||||
|
||||
LOGGER.info("\n========================================================="
|
||||
+ "\n "
|
||||
+ "\n Please press 'q + Enter' to quit the application. "
|
||||
+ "\n "
|
||||
+ "\n=========================================================" );
|
||||
LOGGER.info("\n========================================================="
|
||||
+ "\n "
|
||||
+ "\n Please press 'q + Enter' to quit the application. "
|
||||
+ "\n "
|
||||
+ "\n=========================================================");
|
||||
|
||||
System.out.print("Please enter a non-negative numeric value and press <enter>: ");
|
||||
System.out.print("Please enter a non-negative numeric value and press <enter>: ");
|
||||
|
||||
while (true) {
|
||||
|
||||
final String input = scanner.nextLine();
|
||||
|
||||
if("q".equals(input.trim())) {
|
||||
break;
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
int triggerPeriod = Integer.valueOf(input);
|
||||
|
||||
System.out.println(String.format("Setting trigger period to '%s' ms", triggerPeriod));
|
||||
|
||||
trigger.setPeriod(triggerPeriod);
|
||||
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("An exception was caught: " + e);
|
||||
}
|
||||
while (true) {
|
||||
|
||||
System.out.print("Please enter a non-negative numeric value and press <enter>: ");
|
||||
|
||||
}
|
||||
final String input = scanner.nextLine();
|
||||
|
||||
LOGGER.info("Exiting application...bye.");
|
||||
if ("q".equals(input.trim())) {
|
||||
break;
|
||||
}
|
||||
|
||||
System.exit(0);
|
||||
try {
|
||||
|
||||
}
|
||||
int triggerPeriod = Integer.valueOf(input);
|
||||
|
||||
System.out.println(String.format("Setting trigger period to '%s' ms", triggerPeriod));
|
||||
|
||||
trigger.setPeriod(triggerPeriod);
|
||||
|
||||
}
|
||||
catch (Exception e) {
|
||||
LOGGER.error("An exception was caught: " + e);
|
||||
}
|
||||
|
||||
System.out.print("Please enter a non-negative numeric value and press <enter>: ");
|
||||
|
||||
}
|
||||
|
||||
LOGGER.info("Exiting application...bye.");
|
||||
|
||||
scanner.close();
|
||||
context.close();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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">
|
||||
<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
intermediate/dynamic-poller/src/main/resources/log4j2.xml
Normal file
16
intermediate/dynamic-poller/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>
|
||||
Reference in New Issue
Block a user