[JAVA-8377] Split spring-boot-testing module

This commit is contained in:
Haroon Khan
2021-12-14 23:05:19 +00:00
parent d038cf4cb7
commit f940b84ddd
24 changed files with 526 additions and 2 deletions

View File

@@ -0,0 +1,12 @@
package com.baeldung.boot;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}

View File

@@ -0,0 +1,19 @@
package com.baeldung.component;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
@Component
public class OtherComponent {
private static final Logger LOG = LoggerFactory.getLogger(OtherComponent.class);
public void processData() {
LOG.trace("This is a TRACE log from another package");
LOG.debug("This is a DEBUG log from another package");
LOG.info("This is an INFO log from another package");
LOG.error("This is an ERROR log from another package");
}
}

View File

@@ -0,0 +1,13 @@
package com.baeldung.testloglevel;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication(scanBasePackages = {"com.baeldung.testloglevel", "com.baeldung.component"})
public class TestLogLevelApplication {
public static void main(String[] args) {
SpringApplication.run(TestLogLevelApplication.class, args);
}
}

View File

@@ -0,0 +1,31 @@
package com.baeldung.testloglevel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import com.baeldung.component.OtherComponent;
@RestController
public class TestLogLevelController {
private static final Logger LOG = LoggerFactory.getLogger(TestLogLevelController.class);
@Autowired
private OtherComponent otherComponent;
@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");
otherComponent.processData();
return "Added some log output to console...";
}
}