在 logback-spring.xml 中,我知道可以访问环境属性(在我的情况下是活动配置文件),但我正在寻找 groovy 等效项。
There's no equivalent for logback.groovy
. As things stand, if you want to access the environment or the active profiles in your logging configuration you'll need to use logback-spring.xml
.
If you'd like to see equivalent support in logback.groovy
, please open an enhancement request .
This is the way:
import static org.springframework.core.env.AbstractEnvironment.ACTIVE_PROFILES_PROPERTY_NAME
def profiles = (System.getProperty(ACTIVE_PROFILES_PROPERTY_NAME) ?: '').split(',')
Then use like
if (profiles.contains('DEV')) {
...
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.