How to put log file in user home directory in portable way in logback?

Dims :

I would like to put log file into user home directory.

How to do that in portable way, i.e. working on Windows, Linux and Mac?

xav :

According to Logback documentation, you should use ${user.home}, which is an environment variable present in the JVM directly coming from the OS (so it is portable):

<appender name="FILE" class="ch.qos.logback.core.FileAppender">
    <file>${user.home}/logback.log</file>
    <encoder>
        <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%n</pattern>
    </encoder>
</appender>

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=453987&siteId=1