logging - How to choose the location of a log file for a Java application in a platform independent way? -


I am writing a Java application. Currently it generates a file named "trace.txt" in the same directory. This can sometimes cause problems with file permissions, such as writing C: \ Program Files \ Foo \ trace.txt.

After doing some research, SO seems to have a general opinion about entering the app data \ FU for the user. It will not be a place for other OS.

What is the best practice in this situation? I am using java.util.logging.

You can always use USER_HOME, which has been identified in ~ Linux or

System.JetProperty ("UserHome"); In Java

Many apps will have their own .myappname folder, and will keep config files, there will be logs.

This will map to / home / user / myapp or C in Linux: / documents and settings / user /. The map should be in the window, and always writeable.


Comments