where to place logback.xml?

Just started with logback, I made to get work for me. I am used to distribute my Java software as one jar file and a folder "lib/" holding all jars the executable jar depends on. The executable jar specifies the classpath to lib/*. Currently the logback configuration file logback.xml is also covered in the executable jar and is recognized by the application. In case of an issue report from a user, I would like to give the user some instructions to switch to DEBUG loglevel and send me the logging output. What would be the best way to do so? Please note that the classpath is determined by the executable jar. I tried to find a way to put a logback-test.xml on the classpath without rebuilding the application. Unfortunately without success. -- Viele Grüße, Best Regards Rolf Schumacher p.s.: Did I understood it right that I cannot change the loglevel - e.g. to DEBUG - programmatically? If so I would just tell the user to supply a commandline parameter specifying the loglevel to run with.

As documented in https://logback.qos.ch/manual/configuration.html <https://logback.qos.ch/manual/configuration.html> You can specify a particular config file like this:
You may specify the location of the default configuration file with a system property named"logback.configurationFile". The value of this property can be a URL, a resource on the class path or a path to a file external to the application.
java -Dlogback.configurationFile=/path/to/config.xml chapters.configuration.MyApp1 If you don’t want to override the whole file, but just want to be able to set debug level just by setting a system, then see my answer here: http://stackoverflow.com/a/5884505/191084 <http://stackoverflow.com/a/5884505/191084> Thanks David

Thank you for your answer, David there are several options to solve my use-case. Form the link you provided I have chosen the method, applying "-Dlog.level=INFO". --- Viele Grüße, Best Regards Rolf Schumacher Am 30.03.2017 22:08, schrieb David Roussel:
As documented in https://logback.qos.ch/manual/configuration.html [2]
You can specify a particular config file like this:
You may specify the location of the default configuration file with a system property named"logback.configurationFile". The value of this property can be a URL, a resource on the class path or a path to a file external to the application.
java -DLOGBACK.CONFIGURATIONFILE=/PATH/TO/CONFIG.XML chapters.configuration.MyApp1
If you don't want to override the whole file, but just want to be able to set debug level just by setting a system, then see my answer here: http://stackoverflow.com/a/5884505/191084 [3]
Thanks
David
_______________________________________________ logback-user mailing list logback-user@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-user [1]
Links: ------ [1] http://mailman.qos.ch/mailman/listinfo/logback-user [2] https://logback.qos.ch/manual/configuration.html [3] http://stackoverflow.com/a/5884505/191084

Hi Rolf, Logback will reload logback.xml if detects that the file has changed. Configuration files can be included [1] and change detection applies to included files as well. You can instruct the user to create/modify the included config file. Let us know if it works for you. -- Ceki [1] https://logback.qos.ch/manual/configuration.html#fileInclusion On 3/30/2017 12:54 PM, Rolf Schumacher wrote:
Just started with logback, I made to get work for me.
I am used to distribute my Java software as one jar file and a folder "lib/" holding all jars the executable jar depends on. The executable jar specifies the classpath to lib/*.
Currently the logback configuration file logback.xml is also covered in the executable jar and is recognized by the application.
In case of an issue report from a user, I would like to give the user some instructions to switch to DEBUG loglevel and send me the logging output.
What would be the best way to do so?
Please note that the classpath is determined by the executable jar. I tried to find a way to put a logback-test.xml on the classpath without rebuilding the application. Unfortunately without success.

Thank you for your reply, Ceki. David gave the answer that where useful for my use-case. You see, when the logback.xml file is hidden in a jar file, it is not easy for an end-user to change it. --- Viele Grüße, Best Regards Rolf Schumacher Am 31.03.2017 07:05, schrieb Ceki Gulcu:
Hi Rolf,
Logback will reload logback.xml if detects that the file has changed. Configuration files can be included [1] and change detection applies to included files as well.
You can instruct the user to create/modify the included config file.
Let us know if it works for you.
-- Ceki
[1] https://logback.qos.ch/manual/configuration.html#fileInclusion
On 3/30/2017 12:54 PM, Rolf Schumacher wrote:
Just started with logback, I made to get work for me.
I am used to distribute my Java software as one jar file and a folder "lib/" holding all jars the executable jar depends on. The executable jar specifies the classpath to lib/*.
Currently the logback configuration file logback.xml is also covered in the executable jar and is recognized by the application.
In case of an issue report from a user, I would like to give the user some instructions to switch to DEBUG loglevel and send me the logging output.
What would be the best way to do so?
Please note that the classpath is determined by the executable jar. I tried to find a way to put a logback-test.xml on the classpath without rebuilding the application. Unfortunately without success.
_______________________________________________ logback-user mailing list logback-user@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-user

Glad you could find a solution you are happy with. Note in my suggestion, that the user would change the included file, not the "main" logback.xml file located within the jar. On 3/31/2017 4:21 AM, Rolf Schumacher wrote:
Thank you for your reply, Ceki.
David gave the answer that where useful for my use-case.
You see, when the logback.xml file is hidden in a jar file, it is not easy for an end-user to change it.
--- Viele Grüße, Best Regards
Rolf Schumacher
Am 31.03.2017 07:05, schrieb Ceki Gulcu:
Hi Rolf,
Logback will reload logback.xml if detects that the file has changed. Configuration files can be included [1] and change detection applies to included files as well.
You can instruct the user to create/modify the included config file.
Let us know if it works for you.
-- Ceki
[1] https://logback.qos.ch/manual/configuration.html#fileInclusion
On 3/30/2017 12:54 PM, Rolf Schumacher wrote:
Just started with logback, I made to get work for me.
I am used to distribute my Java software as one jar file and a folder "lib/" holding all jars the executable jar depends on. The executable jar specifies the classpath to lib/*.
Currently the logback configuration file logback.xml is also covered in the executable jar and is recognized by the application.
In case of an issue report from a user, I would like to give the user some instructions to switch to DEBUG loglevel and send me the logging output.
What would be the best way to do so?
Please note that the classpath is determined by the executable jar. I tried to find a way to put a logback-test.xml on the classpath without rebuilding the application. Unfortunately without success.
_______________________________________________ logback-user mailing list logback-user@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-user
participants (3)
-
Ceki Gulcu
-
David Roussel
-
Rolf Schumacher