<%
Dim strErrEvent
On Error Resume Next
... some code or event that may fail due to an error
If Err Then
' in the event of an error, write the page path,
' error number and error description to the log file...
strErrEvent = Request.ServerVariables("PATH_INFO") & vbTab & _
Err.Number & vbTab & Err.Description
WriteLog Server.Mappath("/website_errors.txt"), strErrEvent
End If
On Error GoTo 0
%>
<%
Private Sub WriteLog(byVal pathname, byVal logevent)
Dim objFSO, objFile
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile(pathname, 8, True)
objFile.WriteLine Now() & vbTab & logevent
objFile.Close
Set objFile = Nothing
Set objFSO = Nothing
End Sub
%>