简体   繁体   中英

How to set absolute logdir in spring-boot?

https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-logging.html

According to the docs above, I could set the logpath and filename as follows.

logging.file=/var/log/mylog.log .

BUT: I see the logging to console, but the logfile is never writter (nowhere on the filesystem!).

When I change the property as follows:

logging.file=var/log/mylog.log . Then I'm getting the log in classpathroot/var/log/mylog.log .

Question: why is it working under the classpath root, but not in /var/log ?

If you use relative path in the value of logging.file , it will save log in under current directory. As it is mentioned in the section.

Writes to the specified log file. Names can be an exact location or relative to the current directory.

But if you provide absolute path in the value. Then there is no problem at all. But i think in your case you had put a directory which is not permitted to write file by the user you were trying to run the application.

Better to provide a directory which having permission to write file or give the permission to the application user (which will run application) to write file in the given directory.

use logging.path=/var/log/mylog.log as indicated here
https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-logging.html section 26.3

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM