2

In my Spring Boot project, I initially set up the logging configuration in the application.properties, e.g.

logging.file=/foo/bar/app.log
logging.file.max-size=1M
logging.file.max-history=10
logging.file.level.root=DEBUG
logging.file.level.root.com.my.app=DEBUG
logging.file.level.org.springframework.boot.diagnostics=DEBUG
logging.file.level.org.springframework.security=DEBUG

Let's say I have other environment-specific properties files named following this pattern application-xxx.properties with xxx being the Spring profile name passed as argument when running the app (via -Dspring.profiles.active=xxx).

In these files, I can override the log levels, e.g. for an application-qa.properties

logging.file.level.root=INFO
logging.file.level.root.com.my.app=INFO
logging.file.level.org.springframework.boot.diagnostics=INFO
logging.file.level.org.springframework.security=INFO

I can also override these in the command line with the same mechanism as explained above (-D ).

Now, I'm asked to transfer all this configuration into a single logback-spring.xml. Using this new style of configuration, is there a way to still override each properties?

Found these resources while looking for an answer:

maxxyme
  • 2,164
  • 5
  • 31
  • 48
  • have you looked into this? https://docs.spring.io/spring-boot/docs/current/reference/html/features.html#features.logging.logback-extensions.profile-specific – bananas Jun 21 '22 at 08:17
  • @bananas I have. But my question remains the same: is there a way to still override these properties? – maxxyme Jun 22 '22 at 12:52

0 Answers0