Exception Logging to the Event Log


/ Published in: Visual Basic
Save to your folder(s)

A helper class which adds the ability to log exceptions to the Windows event log, including the class and method in which they occurred, to a class that derives from it.
The event source name defaults to the application title, but can be overridden by passing a string to the constructor (i.e. MyBase.New("MyApp") in the derived class).

e.g.

Public Class Test
Inherits ExceptionLogger

Public Sub Test()
Try
Throw New ApplicationException("Test exception", New Exception("Test inner exception"))
Catch ex As Exception
LogException(ex)
End Try
End Sub
End Class

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.