Search code examples
springloggingspring-bootspring-el

Getting the user home path in application.properties in Spring Boot


This should be a quite straight forward task, but after doing quite a bit of research I'm finding it hard to find any way to do this.

I just want to create a log file in the current user's home directory. According to the Official Documentation the variables I should modify are logging.file and logging.path. But how do I get the value of the user-home into the logging.path?

I have tried setting it up like:

logging.path=#{systemProperties['user.home']}

but without any success.


Solution

  • I believe I have solved the problem. The log file in question was actually being generated in the class path only when run from the IDE (Eclipse Luna FYI). Later on when I made a jar file and ran that, the log file was being generated in the right location as specified in the application.properties file. I still have no clue to why it was generated in the class path when I ran it from Eclipse.