1

I have a simple application with a simple logback.xml file, which I do not wish to put on the classpath. I can guarantee that it will be present where the application is run from, though.

I tried --logging.config=file:./logback.xml, but spring does not seem to honor the setting. What is the recommended way to achieve this? Thanks!

mac01021
  • 745
  • 4
  • 13
  • You can use resource plugin and keep it wherever you want. – Indra Uprade Jul 20 '16 at 22:11
  • Sprinboot made it very easy to write logs to external files. Just change the path from whitin the application.properties file. See my answer here http://stackoverflow.com/questions/38527175/spring-boot-no-log-file-written-logging-file-is-not-respected?noredirect=1#comment64554948_38527175 – AchillesVan Jul 26 '16 at 09:15
  • @Georgesvanhoutte: I was trying to specify the location of the config file, not the output file. – mac01021 Jul 27 '16 at 11:49
  • Ok. Then you should override Spring Boot auto-configuration with explicit configuration like @PropertySource annotation; See doc : http://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/context/annotation/PropertySource.html – AchillesVan Jul 27 '16 at 12:41

1 Answers1

1

It should be easy, as Logback has a feature for this purpose:

java -Dlogback.configurationFile=/path/to/config.xml ...

You can read more in the logback documentation.

G. Demecki
  • 10,145
  • 3
  • 58
  • 58