Name

AppendToLog

Synopsis

Response.AppendToLog(ByVal param As String)

Appends the text specified by the param argument to the IIS log file for the current IIS application.

Parameters

param

A String argument containing the text to be appended to the IIS log.

Example

The following example writes a message to the IIS log for the application the page is a part of, and then writes a message to the ASP.NET Message label control indicating that the message was written:

Sub Page_Load(  )
   Response.AppendToLog("Hello from Page_Load!")
   Message.Text = "Message written to IIS Log!"
End Sub

The IIS log entry generated by the example above looks similar to the following:

2001-10-14 00:13:14 127.0.0.1 - 127.0.0.1 80 GET 
/ASPdotNET_iaN/Chapter_17/AppendToLog.aspx 
Hello+from+Page_Load! 200 BrowserString

Notes

Unlike the AppendToLog method in classic ASP, which had a limit of 80 characters per call, you can write as much text as you wish to the log by using AppendToLog in ASP.NET. The IIS Log files are located by default in %windir%\System32\LogFiles\W3SVCx\exdate.log, where %windir% is the name of the Windows directory, x is the number of the Web site for the log (this is the IIS Metabase name for the desired application), and date is the creation date of the log file.

Get ASP.NET in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.