views:

818

answers:

5

I have a asp.net application that we've written our own logging module for.

My question is, where is the standard place to write a log file to? I.e. the website will be running as the anonymous user identity (e.g. IUSR on IIS7) and I need a place where I know it'll have permission to write to.

Cheers,

+3  A: 

App_Data folder on the root of the project. It isn't served to web requests; so other people can't snoop for it.

EndangeredMassa
+1  A: 

I would suggest putting the log file onto a seperate disk, though should give you a little performance gain so that your not trying to both read and write to the same disk as the website. If you cannot put the log file on a seperate disk, then I would simply choose a folder of your choice.

In any case, you will have to give the "Network Service" account "Modify" permissions to the desired folder.

If on the other hand, you have access to a databse, then log the information there. It will be much quicker than accessing the hard drive and won't be publically available. You'll also be able to report from the data quite easily.

GateKiller
A: 

I'm not in a position to modify the permissions on folders (especially outside of the virtual directory home folder), and don't already have an App_Data folder, so am a bit hesitant to go with that.

So for the moment I'm going with the CommonApplicationData Folder.

  • On Vista/Server 2008 this is C:\ProgramData\
  • On XP/Server 2003 this is C:\Documents and Settings\All Users\Application Data\
Ray
A: 

I'm not in a position to modify the permissions on folders (especially outside of the virtual directory home folder), and don't already have an App_Data folder, so am a bit hesitant to go with that.

If you have a website, you clearly have a folder somewhere. Can you not add a (non-web-facing) subfolder? It seems like that would be a more appropriate place to put your logs than dumping them into a global, shared folder.

Derek Park
A: 

You could also log to the Windows Event log or to a table in a database. How often are people looking at the event log? If it's being examined on a regualr basis, writing to a table amkes the reporting back much easier as it's trivial to reverse the order and only show the last X events for the current time period. The Windows Event log you can also query the Windows Event Log through PowerShell or with LogParser.

Chris Miller