3

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?

Jason
  • 11,709
  • 9
  • 66
  • 82

1 Answers1

2

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.

Community
  • 1
  • 1
Jonas Tonny
  • 172
  • 1
  • 8
  • 1
    User.home or tempdir perhaps ? – Marged Dec 03 '15 at 18:21
  • Yes, but only from a normal Java Desktop application. But keep in mind that for some companies it will be difficult to sync user directories when they contain big files. Windows does not like this when it has roaming profiles. – Marged Dec 03 '15 at 18:51
  • That's a good point. I can see that would be a problem if the log produced was in the size of gigabyte. However, that's too big for a log in the users end any way. – Jonas Tonny Dec 03 '15 at 18:57
  • The company I work for sets a 100 MB quota because when sync takes too long profiles often get corrupted. And this is for all applications ! – Marged Dec 03 '15 at 19:09