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/Applicat
Thank you all for the inputs. based on the hint that Alex proposed I went with the following approach,
In log4j.properties I had the following configuration
log4j.appender.FILE=org.apache.log4j.RollingFileAppender
log4j.appender.FILE.File=${userApp.root}/logs/myapp.log
and at the start of the application I have done this.
System.setProperty("userApp.root", getUserAppDirectory());
the getUserAppDirectory() method is defined as
static String getUserAppDirectory() {
if (isMacOS())
return System.getProperty("user.home") + "/Library/Application Support/myapp";
else
return System.getenv("APPDATA") + "/myapp";
}