Where should I put my log file for an asp.net application?

I have an ASP.NET application for which we have created our own logging module.

My question is: where is the standard place to write the log file? That is, the site will work as an anonymous user identifier (for example, IUSR on IIS7), and I need a place where I know that it will have write permission.

Greetings

+7
logging permissions
source share
6 answers

The App_Data folder in the root of the project. It is not served by web requests; so other people cannot track it.

+6
source share

I would suggest placing the log file on a separate disk, but should give you a slight increase in performance so that you do not try to read and write to the same disk as on the website. If you cannot put the log file on a separate drive, I would just select the folder of your choice.

In any case, you will need to provide the “Network Service” account “Change” permissions to the desired folder.

If, on the other hand, you have access to the database, then register information there. This will be much faster than accessing the hard drive and will not be publicly available. You can also easily report from the data.

+1
source share

I can’t change permissions for folders (especially outside the virtual directory’s home folder), and I don’t have the App_Data folder yet, so I’m hesitant to go with this.

So, at the moment, I'm going to the CommonApplicationData folder.

  • In Vista / Server 2008, this is C: \ ProgramData \
  • In XP / Server 2003, this is C: \ Documents and Settings \ All Users \ Application Data \
0
source share

I can’t change permissions for folders (especially outside the virtual directory’s home folder), and I don’t have the App_Data folder yet, so I’m hesitant to go with this.

If you have a website, you obviously have a folder. Can you add a subfolder (not web oriented)? It seems like this would be a better place to host your logs than dumping them into a shared folder.

0
source share

You can also enter the Windows event log or a table in the database. How often do people view the event log? If it is checked on a regular basis, writing to the table simplifies reporting back, since it is trivial to reverse the order and show only the latest X-events for the current time period. In the Windows event log, you can also request the Windows event log through PowerShell or LogParser .

0
source share

Press app_data is the best idea, just keep in mind when publishing projects, if the option "Delete all existing files before publishing" is checked, the current data in the folder will disappear. The workaround is to skip deleting the app_data folder.

Another way to log is to use some existing frameworks such as Log4net.

0
source share

All Articles