Merge pull request #14328 from panos-kakos/JAVA-14013
[JAVA-14013] Added example for LoggingSystem
This commit is contained in:
commit
3f76369a97
|
@ -2,6 +2,8 @@ package com.baeldung.spring.boot.management.logging;
|
|||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.boot.logging.LogLevel;
|
||||
import org.springframework.boot.logging.LoggingSystem;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
@ -21,4 +23,12 @@ public class LoggingController {
|
|||
|
||||
return "See the log for details";
|
||||
}
|
||||
|
||||
@GetMapping("/change-to-error")
|
||||
public String changeLogLevelToError() {
|
||||
LoggingSystem system = LoggingSystem.get(LoggingController.class.getClassLoader());
|
||||
system.setLogLevel(LoggingController.class.getName(), LogLevel.ERROR);
|
||||
|
||||
return "changed log level to error";
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue