programming-examples/asp/FilesMaths/WriteLog Statement.asp
2019-11-18 14:25:58 +01:00

27 lines
823 B
Plaintext

example usage:
<%
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
%>
source code:
<%
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
%>