Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the best practice for log file locations in Java desktop applications?

Tags:

java

logback

I have a Java Webstart application and I want my log output to go to a file. The application must work on Mac OS X and Windows (and it'd be nice to work on Linux and generally any Unix).

I'm using Logback.

Where should I place my log files? Is there standard code to get a file location that is suitable for logs and will adjust the location appropriately for each platform?

like image 649
Jason Avatar asked Oct 22 '25 23:10

Jason


1 Answers

I would in most cases put it in the user's local Application Data directory. That might not be relevant depending on your application.

I found this earlier question relevant when I needed a place to put my logfiles on a Windows machine: Where to store an application log file on Windows

Unfortunately, I don't believe there's a function to get the best location for each platform.

like image 167
Jonas Tonny Avatar answered Oct 25 '25 13:10

Jonas Tonny