views:

20

answers:

2

I would simply like to append an additional value which is generated at runtime in a page to my IIS log entry for the current request (or as an alternative, overwrite one of the standard fields with my custom value).

I can't find a way to do this and I can't find an example of writing a custom log handler in C# (I'm not proficient in С++)

Any help is appreciated, thanks.

+1  A: 

If you were using IIS 7.x you could achieve this using the Advanced Logging extension.

Using this you can source data from custom fields from a number of different sources. There's an article on setting this up here:

Advanced Logging for IIS 7.0 - Custom Logging

In IIS6 you'd need to implement your own custom logger, I don't think there's a way to intercept logging events to the default logger (iislog.dll) and add extra data:

Creating Custom Logging Modules for IIS

Your logger would probably also have to be written in C++ for IIS6 unless you could coerce the .NET runtime to load inside a COM wrapper component.

Kev
A: 

You can use the ASP.NET method called AppendToLog to add any string into the IIS Log files. It will be "appended" to the column that includes the Query string so you can further query it, see: Response.AppendToLog http://msdn.microsoft.com/en-us/library/system.web.httpresponse.appendtolog.aspx

CarlosAg