使用<property name="LOG_PATH" value="./logs/${APP_NAME}"/>
出现LOG_PATH_IS_UNDEFINED
参考stackoverflow大佬回复
Before Spring Boot enviroment is prepared,
the Spring Boot main class or the SpringApplication will initialize the loggerfactory,
which will detect the default configuration file (logback.groovy, logback.xml, l
ogback-test.xml), but at this time the Spring Boot application is not started yet,
which means the variable LOG_PATH is not set.
因为Springboot加载Logfactory的优先级高与SpringBoot的环境准备,所以在加载logback.xml配置文件的时候Spring Boot Application还没有启动 所有在使用LOG_PATH的时候还没有初始化所以出现LOG_PATH_IS_UNDEFINED
我自己的解决办法
配置bootstrap.yml文件.boostrap.yml优先于application.yml加载
logging:
file:
path: ./logs/${spring.application.name}
然后再logback-spring.xml中使用 即可避免出现_IS_UNDEFINED
<springProperty scop="context" name="LOG_PATH" source="logging.file.path" />