Thursday, May 24, 2007

4186.aspx

ASP/ASP.NET Response.AppendToLog() max size limit

Response.AppendToLog() is a great way to log short information with web requests in the IIS log in the "cs-uri-query" field. It makes traffic analysis and troubleshooting a lot simpler as it is possible to enrich the log with information that is not passed in the query string. You can for example log data from the users session:



Response.AppendToLog("&userid=" + Request.Session[userID])


Best of all:



  • The log is written automatically by IIS asynchronously

  • IIS takes care of rolling over the file by hour/day etc

  • The data is logged as part of the request in the IIS log exactly where you need it so you do not have to “join“ data from multiple logs

The documentation I found on the internet claimed that it is only possible to append 80 characters. This is no longer true in IIS 6 where it is possible to append data until the field is 4kb (4096 bytes)


The IIS log system has, in my opinion, one bug. If the total length of the cs-uri-query field exceeds 4kb, IIS drops all the data in the cs-uri-query field and only logs "…". I expect it to log 4093 bytes of data from the log plus a trailing "…"

No comments:

Post a Comment