How can we load logback.xml via jvm argument if this is not present in project classpath?
I'm using
-Dlogback.configuration=file:C:\logbacs\logback.xml
but this is not working.
How can we load logback.xml via jvm argument if this is not present in project classpath?
I'm using
-Dlogback.configuration=file:C:\logbacs\logback.xml
but this is not working.
I found the solution
-Dlogging.config="C:\logbacs\logback.xml"
is working fine for me.
Updated because the previous answer was obsolete
If you're not using SpringBoot the above won't work.
I'm using the ch.qos.logback.logback-classic library, and in this case the solution is
-Dlogback.configurationFile=file:/app/logback.xml
I've found this property in ch.qos.logback.classic.util.ContextInitializer:
final public static String CONFIG_FILE_PROPERTY = "logback.configurationFile"
The original answer to this question doesn't appear to be working anymore as it produces this warning instead:
o.s.b.l.logback.LogbackLoggingSystem : Ignoring 'logback.configurationFile' system property. Please use 'logging.config' instead.
Therefore, you would want to use something like this:
-Dlogging.config="C:\logbacs\logback.xml"
As per https://logback.qos.ch/manual/configuration.html, use -Dlogback.configurationFile
java -Dlogback.configurationFile=/path/to/config.xml chapters.configuration.MyApp1