views:

415

answers:

6

Where would be the best "standard" place to put an application's debug log file in a Windows user environment?

In this particular case, it is an application that is run once and could go wrong. It will be run by system administrator types who may need to inspect the log after the application is run. Everytime the application is run, a new log file is created.

Options that have been floated so far include:

  1. The program directory
  2. The user's desktop
  3. The user's local Application Data directory.

I have my favourite, but I wondered what the SO consensus was.

Note: this is similar to this question, but we're dealing with an application that's only likely to be run once by one user.

A: 

Windows Temp Folder

Zote
Why? Who would ever look for a log file there. It's not a temporary file, IMO.
Thomas Owens
He told "an application that's only likely to be run once by one user" with this information I think that is an temporary log and temporary application.
Zote
+3  A: 

The "standard" place for the log would be the AppData directory. However, really its up to you where you want to store them. As they are administrator (power users) then there should be no problems storing the logs in the same directory as the application being run. Even in the MyDocuments of the user would be a good shout.

James
Good point, but I would discourage recording things into My Documents or the Desktop - those are the user's places and I don't think applications should write anything to them unless directed to do so by the user.
Thomas Owens
It isn't uncommon for applications (by default) to save items in the MyDocuments folder e.g. templates. Visual Studio does this as does Delphi.
James
I personally get annoyed when things save things to My Documents, but that's me. One of the arguments against AppData is that it's not easily "discoverable" by users, so My Documents might be better...
Darcy Casselman
+2  A: 

1.The program directory <- not good. Ideally you will only have RX permissions on this folder.

2.The user's desktop <- technically can be done, but I don't like this idea. Polluting desktop... I, as a user, don't like it.

3.The user's local Application Data directory. <- better

My preference is a subdirectory under the program directory (with a clear name like "DebugLog" or something similar). Permissions on that subdirectory should allow creating and writing files ("Change" will be fine)

DmitryK
Using anything under the Program Directory is a bad idea because that is shared amongst any user who uses the machine. Would you then grant anybody read/write permission to this DebugLog directory? Then you have security issues, different users overwriting eachothers' log files, etc.... Your #3 is the right answer IMHO.
RichAmberale
You are quite right. In this particular case though (debug logging) a subdirectory is acceptable in my view. (this is not a standard way of using this software, but rather an exception). So it is OK to allow debugging log to be stored in a Debug subdirectory. Debugging logs should be created with unique names to prevent overwriting.
DmitryK
+1  A: 

I the organization I work for we use the (%TEMP% or %TMP%)\CompanyOrProductName\Logs directory Using %APPDATA% may be problematic with roaming profiles if the logs are numerous or huge : it slows their login process ...

GoJiTa972
Good point. Something to keep in mind when dumping stuff in AppData.
Darcy Casselman
+1  A: 

If you EXPECT something to go wrong put it in the user's local Application Data directory.

If you don't and just want to log anyways I might think about really using the temp directory. The reasoning for this is simple. If the application is only run once you will leave trash in the Application Data directory otherwise that nobody will ever need again. In the temp you have at least the CHANCE that it's going to be cleaned up later.

BTW: IMHO the best would be not not create the log AS A FILE at all (log to memory) until something goes wrong. Then you can still offer a dialog where the user selects where to save the log.

Foxfire
+3  A: 

The Application Data directory would seem to be the perfect place, but it's an area that is nearly invisible. You need to give your users an easy way to get to it.

Have your installation script create a Log folder in the Application Data area for your program, and include a link to the folder in your Start menu.

Mark Ransom
The AppData folder is the best place, but it does need a link from the program or start menu to allow easy access, even for admin type people. Why don't you just pop up the log file at the end of the run, or open an explorer window for the AppData folder?The ProgramFiles folder is wrong, Vista onwards sees that as read only unless you are an installer program. The user documents and desktop are bad choices, they should be left clear for documents the user has created (typed, downloaded) not logs.
Martin
Sounds like a good ideas to me...
Darcy Casselman