首页 > 解决方案 > Can I move Spring Boot logging settings out of application.properties file and into an untracked file?

问题描述

I am working on building a SpringBoot app with my workmates. We all have different preferred logging levels for the app. We have been battling back and forth with each other's logging changed to application.properties. Is there a way to move all of the logging.level.* stuff out of that application.properties file and into a ~logging.properties file or something? That way we can add that file to the .gitignore and not track that file so we can each leave our logging alone. We are using Java annotations and not xml btw.

I've tried adding @PropertySource("classpath:logging.properties") to the application file, but I read somewhere that the logging gets setup early on in the init process and this won't work. I tried it anyway and it doesn't work (so confirmed I guess).

I can't believe there's isn't more info on this out there.. I'd imagine the members of a dev team each want their own custom level of logging and don't want to keep stepping on each other's toes/commits.

标签: springspring-bootlogging

解决方案


您可以使用命令行属性覆盖它。回退策略将命令行 -D args 作为最高优先级。

https://docs.spring.io/spring-boot/docs/current/reference/html/spring-boot-features.html#boot-features-external-config


推荐阅读