BAEL-1970 spring logging level while testing

This commit is contained in:
mprevisic
2019-03-23 19:04:55 +01:00
parent b9ffaea139
commit 19ec10a630
11 changed files with 309 additions and 0 deletions
@@ -0,0 +1,22 @@
package com.baeldung.testlog;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class TestLog {
Logger LOG = LoggerFactory.getLogger(this.getClass());
public void info(String msg) {
LOG.info(msg);
}
public void error(String msg) {
LOG.error(msg);
}
public void trace(String msg) {
LOG.trace(msg);
}
}
@@ -0,0 +1,15 @@
package com.baeldung.testloglevel;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import com.baeldung.boot.Application;
@SpringBootApplication
public class TestLogLevelApplication {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
@@ -0,0 +1,29 @@
package com.baeldung.testloglevel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import com.baeldung.testlog.TestLog;
@RestController
public class TestLogLevelController {
Logger LOG = LoggerFactory.getLogger(this.getClass());
@GetMapping("/testLogLevel")
public String testLogLevel() {
LOG.trace("This is a TRACE log");
LOG.debug("This is a DEBUG log");
LOG.info("This is an INFO log");
LOG.error("This is an ERROR log");
new TestLog().trace("This is a TRACE log in another package");
new TestLog().info("This is an INFO log in another package");
new TestLog().error("This is an ERROR log in another package");
return "Added some log output to console...";
}
}