开发者

Append custom value to IIS logs from ASP.NET

开发者 https://www.devze.com 2023-01-18 21:25 出处:网络
I would simply like to append an additional value which is generat开发者_运维技巧ed at runtime in a page to my IIS log entry for the current request (or as an alternative, overwrite one of the standar

I would simply like to append an additional value which is generat开发者_运维技巧ed 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.


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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消