Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where should a WinForm app keep its logs?

I am working on a WinForm application, that allows working to work with "projects" (think about the application as Visual Studio, and projects as VS Solutions).

My question is - where should the application keep its logging files?

Some requirements include:

  • the application might not be running as an administrator (so saving in the %ProgramFiles% installation folder is not a good option)
  • The logs should be accessible to end-users (either for review, or for sending to the support team). (This means that hard to find folders, like %AppData%\Company\Application\Version\ProjectName... are not a good solution either)
  • The application might generate logs even when there are no open projects (so saving the logs in the project's folder is good only when there's a project, but not a final solution).

I was thinking of creating a "working folder" when the application is installed - something along the lines of C:\Application\, and then save the logs in a subfolder, like %WorkingFolder%\Logs\ProjectName

Thanks for the input.

like image 719
SaguiItay Avatar asked Sep 07 '10 07:09

SaguiItay


2 Answers

Somewhere in the user's directory is actually the correct place to store them if they are specific to the current running user.

Some programs create folders at the top level of the User's directory, next to Documents and Desktop, others do it in Documents.

Creating it in C:\ might cause issues if the user doesn't have write access to the root directory. You can pretty much guarantee the user will have write access to the Home directory.

The other option is to look for an environment variable, and if its set use the value as the location, if not default to the User's home directory.

like image 191
Michael Shimmins Avatar answered Sep 25 '22 16:09

Michael Shimmins


If the logs are user only you should store them at %AppData%\Company\Application Name.

If the logs are shared (any user can see any log) you should store them at:
%ProgramData%\Company\Application Name (for Vista+)
or
%AllUsersProfile%\Application Data\Company\Application Name (for XP-)

As for user access, you can add a shortcut to the start menu to the appropriate location or have a link within the program.

Another option in Vista+ is the Public folder (%Public%) which has links throughout Explorer for easy access to.

Where should I write program data instead of Program Files is a good blog entry by Chris Jackson from Microsoft. While it isn't an "official stance" it holds some excellent information.

like image 23
Joshua Avatar answered Sep 26 '22 16:09

Joshua