BAEL-1970 spring logging level while testing
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
+15
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
+29
@@ -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...";
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user