I have a eclipse RCP application using slf4j/logback to catch all the log messages.
Right now I have the following file appender configured:
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
<file>softmodeler_client.log</file>
<append>true</append>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>[%date] %level: %logger - %m%n</pattern>
</encoder>
</appender>
This writes the log file into the application installation directory.
Some customers do not permit write access in the installation directory.
In that case we redirect the workspace and configurations directory defining the following in the Applicationname.ini
file:
-data
@user.home/AppData/Roaming/Applicationname/workspace
-configuration
@user.home/AppData/Roaming/Applicationname/configuration
Now I would like to configure the logback.xml
like this, pointing the logfile to the writable workspace directory:
<file>${osgi.instance.area}softmodeler_client.log</file>
This results in a FileNotFoundException
, because of the file:/
prefix of the osgi.instance.area
system property.
I did not find another property without the protocol.
My question is how can I configure logback to write into my workspace, without having to modify the logback.xml
every time?
EDIT:
Maybe I can register a listener from where I can set some initial properties?
I would prefer to use an existing system property or programmatically pass a variable to the logging framework. The goal is, not having to configure an additional parameter/variable for every installation (since quite a few and might be missed during updates). Just somehow automatically always write the log file into the workspace directory.