Best place to store configuration files and logs for a Windows service

I am wondering what is the best folder for storing configuration files ( ini , xml ) and log files for Windows service .

According to the list of special folders on msdn , it seems that CommonApplicationData strong> (= C:\ProgramData on Windows Vista / 7 / Server 2008 (R2)) is the best place:

CommonApplicationData = Directory that serves as a shared repository for application-specific data that is shared by all users.

Any other tips?

+4
source share
3 answers

Without big answers, I just resume the following, which I think and heard / read best of all:

  • Configuration files ( ini , xml ) must be stored with the service exe file.

  • Logs: a more modular way is to use a third-party logger (for example, log4net or NLog - this thread is interesting for comparison). The folder in which you will store the log file does not matter much if it meets your needs (the service should have sufficient permissions to write to the folder, think about who needs access to the log file and where).

0
source

The .NET configuration file created in Visual Studio, called myService.exe.config , must be saved in the same location as exe. and this XML not an ini file.

Log files can be saved in a folder like C:\Logs\ServiceName or something else that you like, we usually create a network share in such a folder so that we can check log files from other computers as well, without having to connect to the server, where is the windows service running.

+2
source

For logging, I think the Windows event log is most suitable. If you use the Enterprise Library, it's pretty easy to set up :)

Edit: In addition, I agree that using CommonApplicationData for configuration files is a good choice.

+1
source

All Articles