Creating Log in Event Viewer


Creating Log in Event Viewer

Creating Log in Event Viewer


Imports System.Configuration
Module Module1

Sub Main()
Dim etListener As New EventLogTraceListener("VAMSHI")
Try

If Not (EventLog.Exists("EVENTLOGNAME") And EventLog.SourceExists("EVENTLOGSOURCE")) Then
EventLog.CreateEventSource("EVENTLOGSOURCE", "EVENTLOGNAME")
End If

' Add the event log trace listener to the collection.
Trace.Listeners.Add(etListener)

'here 4 is the application log level - need to get it from app config
' Write output to the event log.
'If iLogLevel <= 4 Then
etListener.WriteLine("UserId: -1 " & "HELLO", "TEST")
'End If
'if log level is error or fatal, flush immediately
'If iLogLevel = LogLevel.ErrorLevel Or iLogLevel = LogLevel.FatalLevel Then
' mqsTraceListener.Flush()
'End If
Catch ex As Exception
Throw ex
End Try
End Sub

End Module


Comments

No responses found. Be the first to comment...


  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: