I’m writing a java application. Currently this produces a file called “trace.txt” in the same directory the .jar file lives. This can sometimes cause issue with file permissions, eg writing to C:\Program Files\Foo\trace.txt.
After a bit of research on SO it seems the general opinion is to log to Application Data\Foo\ for the given user. This won’t be the same location for other OS’s.
What’s the best practice in this situation? I’m using java.util.logging.
You could always use the USER_HOME, identified by ~ in Linux or
System.getProperty(“user.home”); in java.
You’ll see lots of apps have their own .myappname folder, and put config files, logs in there.
This will map to /home/user/.myapp in linux or C:/Documents and settings/user/.myapp in windows, and should always be writable.