11

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,

4

6 回答 6

7

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

于 2008-08-09T02:10:12.800 回答
1

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.

于 2008-08-09T08:47:31.670 回答
0

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\
于 2008-08-10T20:52:20.973 回答
0

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.

于 2008-08-10T20:57:21.433 回答
0

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.

于 2008-08-11T01:45:10.930 回答
0

Push the app_data is the best idea, just bear in mind, when the publishing the projects, if the option "Delete all existing files before publishing" is ticked, then the current data in the folder will be gone. The workaround is to skip the deletion of app_data folder.

Another option to do logging is to use some existing framework such as Log4net.

于 2013-02-13T06:04:34.047 回答