Reputation: 24441
In Spring Boot, I can select/enable logger levels via the application.properties file:
logging.level.org.springframework=DEBUG
logging.level.org.hibernate=ERROR
But is there some way to modify the actual appender thresholds/parameters via the same config file? I know I can do it via my log4j.xml file directly, but was hoping to have some way I can easily do it via a command line parameter.
I've tried stuff like (where I have an appender called console)
logging.appender.console.param.Threshold=DEBUG
but with no success.
As anything like that doable?
Upvotes: 0
Views: 1062
Reputation: 116171
If you're happy to use Logback (Spring Boot's default and preferred logging system), you can do it via command line parameters as long as you provide a suitably configured logback-spring.xml
file first.
You can reference properties from the environment (provided on the command line, in application.properties, etc), in your logback-spring.xml
file. For example:
<springProperty scope="context" name="consoleThreshold" source="logging.appender.console.param.Threshold"/>
You can then use that property elsewhere in the same file using ${consoleThreshold}
.
These capabilities are specific to Logback. There's an open issue that may expand the support to other logging systems. That said, it's highly unlikely that Log4J will be included – it's been declared EOL by Apache and support for it is deprecated in Spring Boot 1.3. Log4J 2 is more likely.
Upvotes: 1