Where to save application logs? [duplicate]

2019-07-03 10:55发布

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!

2条回答
Rolldiameter
2楼-- · 2019-07-03 11:21

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.

查看更多
做个烂人
3楼-- · 2019-07-03 11:41

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

查看更多
登录 后发表回答