[JAVA-14013] Added example for LoggingSystem
This commit is contained in:
parent
cd6661e117
commit
b71e52fc8b
|
@ -2,6 +2,8 @@ package com.baeldung.spring.boot.management.logging;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
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.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
@ -21,4 +23,12 @@ public class LoggingController {
|
||||||
|
|
||||||
return "See the log for details";
|
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