4

Possible Duplicate:
Where to store an application log file on Windows

Windows seems to have several places where different applications store its logs. Windows services and some applications use the Windows event log, others use C:\ProgramData, another one store them to C:\Users(Local/System/Public/Default)\AppData/(Roaming/Local).

I noticed this when developing Windows services that the default (AppData/Roaming) environment variable points to something like C:\Windows\System32\Users\system\AppData\Roaming or other completely ridiculous locations, so I'm wondering if there's any sheet out there where to store logs for: User Applications/User Services/System Services and more general: What are all these application folders for (What belongs where?)

Thanks!

Community
  • 1
  • 1
user1450661
  • 331
  • 1
  • 6
  • 15
  • Seems to be related to this one: http://stackoverflow.com/questions/1572934/where-to-store-an-application-log-file-on-windows?rq=1 – Adrian Oct 23 '12 at 13:23
  • @Adrian Slightly related, but not completely, as I'm also asking for user-unspecific applications and Windows services. Also the general purpose of the different methods for logging (e.g. Windows event log, AppData, Program Data). Thanks for the link, but that one doesn't seem to explain everything. – user1450661 Oct 23 '12 at 13:28

2 Answers2

12

For user specific logs:

  • LocalApplicationData - %APPDATA%/Local/...

For user specific logs tied to the users profile:

  • ApplicationData - %APPDATA%/Roaming/...

For all other logs:

  • CommonApplicationData - %ALLUSERSPROFILE%/...

See Environment.SpecialFolder for other folders.

James
  • 80,725
  • 18
  • 167
  • 237
2

The standard place for the log would be the AppData directory
Using %APPDATA% may be problematic with roaming profiles if the logs are numerous or huge : it slows their login process then u can use directory %TEMP% i.e. windows temperory director

Ravindra Bagale
  • 17,226
  • 9
  • 43
  • 70
  • What do you mean by "AppData directory"? Can you please make an example path? – user1450661 Oct 23 '12 at 13:26
  • AppData is not a good choice. The reason for this is if multiple processes try to write to the same file - issues occur. You have to have a file for each process or a single service that has a queue for logging. It should go to the user's directory if user specific or the event viewer if a service. – tsells Oct 23 '12 at 13:28
  • 1
    @Tsells the location of the log file *has nothing* to do with how multiple processes handle writing to it - that's application specific. The `AppData` directory is *usually* the best place for log files, however, it depends on the application & the purpose of the files. – James Oct 23 '12 at 13:35
  • @James - my point is if you store the log files in a single shared location and you have multiple processes writing to the file - then you run into major issues with processes competing for the same file. An example of this is terminal server. You either have to create a new file per process, implement a queue, write to user specific directory, or use the event viewer. – tsells Oct 23 '12 at 13:42
  • 1
    @tsells I see the point you are trying to make...however, I think you are missing the point I am making. There is no need to have multiple files, implement queues etc. there are loads of good logging tools out there which do all that for you e.g. [NLog](http://nlog-project.org/), [log4net](http://nlog-project.org/) etc. So again, the problems you are mentioning are application specific not anything to do with how/where the logs are stored. – James Oct 23 '12 at 13:46