Java – how to place log files in the user’s home directory in a portable manner in logback?
•
Java
I want to put the log file in the user's home directory
How do I do it in a portable way, i.e. working on windows, Linux and Mac?
Solution
According to logback documentation, you should use ${user. Home}, which is an environment variable existing in the JVM directly from the operating system (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>
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码