BAEL-20875: Move spring-boot-logging-log4j2 into spring-boot-modules

This commit is contained in:
Krzysztof Woyke
2020-01-31 08:38:03 +01:00
parent d0225e59ce
commit cce61b0d53
13 changed files with 2 additions and 3 deletions
@@ -0,0 +1,17 @@
package com.baeldung.graylog;
import org.apache.log4j.Logger;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class GraylogDemoApplication {
private final static Logger LOG =
Logger.getLogger(GraylogDemoApplication.class);
public static void main(String[] args) {
SpringApplication.run(GraylogDemoApplication.class, args);
LOG.info("Hello from Spring Boot");
}
}
@@ -0,0 +1,37 @@
package com.baeldung.springbootlogging;
import org.apache.logging.log4j.LogManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class LoggingController {
private final static Logger logger = LoggerFactory.getLogger(LoggingController.class);
@GetMapping("/")
public String index() {
logger.trace("A TRACE Message");
logger.debug("A DEBUG Message");
logger.info("An INFO Message");
logger.warn("A WARN Message");
logger.error("An ERROR Message");
return "Howdy! Check out the Logs to see the output...";
}
private static final org.apache.logging.log4j.Logger loggerNative = LogManager.getLogger(LoggingController.class);
@GetMapping("/native")
public String nativeLogging() {
loggerNative.trace("This TRACE message has been printed by Log4j2 without passing through SLF4J");
loggerNative.debug("This DEBUG message has been printed by Log4j2 without passing through SLF4J");
loggerNative.info("This INFO message has been printed by Log4j2 without passing through SLF4J");
loggerNative.warn("This WARN message been printed by Log4j2 without passing through SLF4J");
loggerNative.error("This ERROR message been printed by Log4j2 without passing through SLF4J");
loggerNative.fatal("This FATAL message been printed by Log4j2 without passing through SLF4J");
return "Howdy! Check out the Logs to see the output printed directly through Log4j2...";
}
}
@@ -0,0 +1,28 @@
package com.baeldung.springbootlogging;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import lombok.extern.slf4j.Slf4j;
//import lombok.extern.log4j.Log4j2;
//import lombok.extern.apachecommons.CommonsLog;
@RestController("LombokLoggingController")
@Slf4j
// @CommonsLog (Comment any other Lombok logging annotation and uncomment this
// to work with Apache Commons Logging)
// @Log4j2 (Comment any other Lombok logging annotation and uncomment this to
// work directly with Log4j2)
public class LombokLoggingController {
@GetMapping("/lombok")
public String index() {
log.trace("A TRACE Message");
log.debug("A DEBUG Message");
log.info("An INFO Message");
log.warn("A WARN Message");
log.error("An ERROR Message");
return "Howdy! Check out the Logs to see the output...";
}
}
@@ -0,0 +1,12 @@
package com.baeldung.springbootlogging;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class SpringBootLoggingApplication {
public static void main(String[] args) {
SpringApplication.run(SpringBootLoggingApplication.class, args);
}
}