Currently we use log4net and create a new folder (usually below C:) with write and create access rights for the worker process user. Is there perhaps a standard windows folder we should or could be using such as LOCALAPPDATA? I'm guessing that LOCALAPPDATA is a bad choice in the general case because IIS users tend to be non-interactive users and thus I don't think they have the usual user folder structrues available.
3 Answers
Put your logs in the App_Data folder below your web site root.
Microsoft guidance: To improve the security of the data used by your ASP.NET application, a new subfolder named App_Data has been added for ASP.NET applications. Files stored in the App_Data folder are not returned in response to direct HTTP requests, which makes the App_Data folder the recommended location for data stored with your application, including .mdf (SQL Server Express Edition), .mdb (Microsoft Access), or XML files. Note that when using the App_Data folder to store your application data, the identity of your application has read and write permissions to the App_Data folder.

- 4,298
- 3
- 21
- 17
-
The web application does not have write access to that directory by default! But here's now to add that: http://stackoverflow.com/a/7334485/143684 – ygoe Jun 02 '14 at 08:48
I would not use c:\ at all. You never know how big your logfiles may grow and one day your System Partition is full.
Other then that I don't know of a standard logging folder, but why not use the Database?

- 2,137
- 1
- 17
- 38
-
Logging to the database is not a good idea. In addition to adding a lot of extra database overhead, you wouldn't be able to log database connection failures. Writing files is the most robust way to log information. – user1751825 Apr 27 '16 at 07:29
Perhaps you might consider logging to a directory inside the app root. There the worker process certainly has permissions and the log data will be easily discoverable, perhaps even servable.

- 36,396
- 8
- 69
- 90