通过环境变量在Spring Boot中设置日志记录级别 [英] Set Logging Level in Spring Boot via Environment Variable
问题描述
在Spring Boot应用程序中是否可能仅通过环境变量设置日志记录级别?
Should it be possible to set logging levels through environment variables alone in a Spring Boot application?
我不想在Cloud Foundry上运行时使用application.properties
,并且希望在不进行部署的情况下(但在应用重新启动或重新调整以更精确之后)进行更改.
I don't want to use application.properties
as I'm running on Cloud Foundry and want to pick up changes without a deploy (but after the app has restarted, or restaged to be more precise).
我已经尝试设置像LOGGING_LEVEL_ORG_SPRINGFRAMEWORK=TRACE
这样的env var,但这没有效果.但是,将logging.level.org.springframework: TRACE
放入application.properties
确实可以.
I've tried setting env vars like LOGGING_LEVEL_ORG_SPRINGFRAMEWORK=TRACE
but that has no effect. Putting logging.level.org.springframework: TRACE
in application.properties
does work though.
推荐答案
这只是一个主意,但您是否尝试设置
This is just an idea, but did you try setting
_JAVA_OPTIONS=-Dlogging.level.org.springframework=TRACE
?
理论上,这种方式-Dlogging.level.org.springframework=TRACE
将作为默认的JVM参数传递,并且应该影响环境中的每个JVM实例.
Theoretically, this way -Dlogging.level.org.springframework=TRACE
will be passed as default JVM argument and should affect every JVM instance in your environment.
这篇关于通过环境变量在Spring Boot中设置日志记录级别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!