471,616 Members | 1,400 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,616 software developers and data experts.

Creating a custom log

UJ
I am trying to have a service write out to a custom log in the event log.
I'm using the following code:
Dim lsEventSource As String = "test1234"
Dim lsEventLog As String = "CustomLog"

If (Not EventLog.SourceExists(lsEventSource)) Then
EventLog.DeleteEventSource(lsEventSource)
EventLog.CreateEventSource(lsEventSource, lsEventLog)
End If

Dim llogEventLog As EventLog
llogEventLog = New EventLog
llogEventLog.Source = lsEventSource

llogEventLog.WriteEntry("This is a test spot for the event log.")
Can anybody tell me what's wrong with the code? No matter what I put for the
lsEventLog name, it always is being written to the Application log. I've
also tried changing the name of the EventSource to something else just to
see what happens then.....

Nov 21 '05 #1
1 1065
April 15, 2005

The problem is when you create the new event log llogeventlog, you are
not specifying the name of the log...
Dim lsEventSource As String = "test1234"
Dim lsEventLog As String = "CustomLog"

If (Not EventLog.SourceExists(lsEventSource)) Then
EventLog.DeleteEventSource(lsEventSource)
EventLog.CreateEventSource(lsEventSource, lsEventLog)
End If

Dim llogEventLog As EventLog
llogEventLog = New EventLog
llogEventLog.Source = lsEventSource
llogEventLog.Log = lsEventLog ' Add custom log name
llogEventLog.WriteEntry("This is a test spot for the event log.")

This will specify the custom log as the one to write to. Have a great day!

Joseph Bittman MCAD
Microsoft Certified Application Developer
"UJ" <UJ@nowhere.com> wrote in message
news:eA**************@TK2MSFTNGP10.phx.gbl...
I am trying to have a service write out to a custom log in the event log.
I'm using the following code:
Dim lsEventSource As String = "test1234"
Dim lsEventLog As String = "CustomLog"

If (Not EventLog.SourceExists(lsEventSource)) Then
EventLog.DeleteEventSource(lsEventSource)
EventLog.CreateEventSource(lsEventSource, lsEventLog)
End If

Dim llogEventLog As EventLog
llogEventLog = New EventLog
llogEventLog.Source = lsEventSource

llogEventLog.WriteEntry("This is a test spot for the event log.")
Can anybody tell me what's wrong with the code? No matter what I put for
the lsEventLog name, it always is being written to the Application log.
I've also tried changing the name of the EventSource to something else
just to see what happens then.....

Nov 21 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Julien | last post: by
3 posts views Thread by clsmith66 | last post: by
17 posts views Thread by Lee Harr | last post: by
1 post views Thread by Abdo Haji-Ali | last post: by
3 posts views Thread by =?Utf-8?B?R2hpc3Rvcw==?= | last post: by
1 post views Thread by =?Utf-8?B?QXJ0aHVyIFBhcmtlcg==?= | last post: by
1 post views Thread by XIAOLAOHU | last post: by
reply views Thread by leo001 | last post: by
1 post views Thread by ZEDKYRIE | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.