What's the best practice for log file location

2019-05-22 16:58发布

问题:

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?

回答1:

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.



标签: java logback