带有Spring Boot的extern log4.properties文件

ray*_*man 5 spring spring-boot

我用可执行jar运行我的应用程序.

我在/ resources文件夹中有log4j.properties

在prod我想覆盖它并在外部目录中

我怎么能用Spring-Boot做到这一点?

Whi*_*hip 10

如果您不想添加命令行参数,则可以application.properties在启动应用程序的目录上添加其他参数.喜欢:

# log4j configuration for product
logging.config=log4j-prod.properties
Run Code Online (Sandbox Code Playgroud)

然后,这application.properties将覆盖/resources/application.propertieslog4j-prod.properties将在产品环境中使用.请阅读更多详情:

http://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-external-config.html#boot-features-external-config-application-property-files