log4j log file in user home directory

Viewed 55772

I am working on an application that will run on OSX and windows. I want the logs to be written to the users home directory. For OSX it will be under the /Users//Library/Application Support/MyApp/log directory, and under windows depending on the version under /Users//AppData/MyApp/log directory.

What is the best way I can do this? I have looked around for solutions for this, but nothing helpful or a solution I am comfortable using has come up.

Look forward to your inputs.

edit: Since the location of the log file depends on the OS, I am hoping to find a run time solution, possibly something like below

if (System.getProperty("os.name").contains("mac"))
    logFileLocation = System.getProperty("user.home") + "/Library/Application Support/MyApp/logs"
else
    logFileLocation = System.getenv("APPDATA") + "/MyApp/logs"

Thanks

4 Answers
Related