EventLog problem

  • Thread starter Bob Anderson via .NET 247
  • Start date
B

Bob Anderson via .NET 247

When I run the VB.NET program below, the entry below appears inthe "Application" log.
The "ServOneLog" log is created, but it is empty. I am trying towrite to the "ServOneLog".
Why doesn't this work??

Application log entry:
The description for Event ID ( 0 ) in Source ( ServOne ) cannotbe found. The local computer may not have the necessary registryinformation or message DLL files to display messages from aremote computer. You may be able to use the /AUXSOURCE= flag toretrieve this description; see Help and Support for details. Thefollowing information is part of the event: LogWorker succeededin writing to ServOneLog..



Program:

Module Module1

Dim el As EventLog

Public Const LOG_NAME As String = "ServOneLog"
Public Const LOG_SOURCE As String = "ServOne"


Sub Main()

Dim appLog As New EventLog("Application")

appLog.Clear()


If (System.Diagnostics.EventLog.SourceExists(LOG_SOURCE))Then
EventLog.DeleteEventSource(LOG_SOURCE)
End If

If System.Diagnostics.EventLog.Exists(LOG_NAME) Then
System.Diagnostics.EventLog.Delete(LOG_NAME)
End If

If (NotSystem.Diagnostics.EventLog.SourceExists(LOG_SOURCE)) Then
EventLog.CreateEventSource(LOG_SOURCE, LOG_NAME)
End If

el = New EventLog(LOG_NAME)
el.Log = LOG_NAME
el.Source = LOG_SOURCE

el.WriteEntry(LOG_SOURCE, "LogWorker succeeded in writingto ServOneLog.")

End Sub


End Module
 
L

Luciano Caixeta Moreira

Bob, i'm having the same problem.
My code is in C# but do almost the same:
- check to see if the source is linked to some log
- if the source existis in some log, delete the source in that log and
associate it with other log
- write entry in the EventViewer

To extend your explanation, i will illustrate mine scenario:

Before creating a new log called "MyLog", i have a key in the windows
registry like this:
-
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Eventlog\Application\My
Source

This entry indicates that a source called MySource can write in
Application log. When i execute my code, it creates a new log, deletes
MySorce from the application and associate it with MyLog, then it write a
message to the EV.
Examining the registry and EV:

- In
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Eventlog\Application\
the key "MySource" has been erased.
- The keys
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Eventlog\MyLog\MyLog
and
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Eventlog\MyLog\MySource
have been created.
- In EV a log called MyLog has been created.

With this configuration, the expected result with the following code is
to write Hello World in a entry at MyLog.

EventLog log = new EventLog();
log.Log = "MyLog";
log.Application = "MySource";
log.WriteEntry = "Hello World!!";

But it writes this entry in the Application Log (***** source = MySource
*****) with the message: "The description for Event ID ( 0 ) in Source (
MySource) cannot be found. The local computer may not have the necessary
registry information or message DLL files to display messages from a remote
computer. You may be able to use the /AUXSOURCE= flag to retrieve this
description; see Help and Support for details....".
But how EV does that, if in the registry the source MySource is
associated with MyLog?? We should receive an error!

If i try to write a message from a different source, like "MyNewSource",
in the same log (MyLog) the EV creates another entry in the application log,
but sucessful creates this key at the registry:

-
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Eventlog\MyLog\MyNewSou
rce.

I'll continue trying to find an answer to that, if you have more sucess,
tell us! Gool luck.

[]s

Luciano Caixeta Moreira
Brazil

===========================================================
"Bob Anderson via .NET 247" <[email protected]> escreveu na mensagem
When I run the VB.NET program below, the entry below appears in the
"Application" log.
The "ServOneLog" log is created, but it is empty. I am trying to write to
the "ServOneLog".
Why doesn't this work??

Application log entry:
The description for Event ID ( 0 ) in Source ( ServOne ) cannot be found.
The local computer may not have the necessary registry information or
message DLL files to display messages from a remote computer. You may be
able to use the /AUXSOURCE= flag to retrieve this description; see Help and
Support for details. The following information is part of the event:
LogWorker succeeded in writing to ServOneLog..



Program:

Module Module1

Dim el As EventLog

Public Const LOG_NAME As String = "ServOneLog"
Public Const LOG_SOURCE As String = "ServOne"


Sub Main()

Dim appLog As New EventLog("Application")

appLog.Clear()


If (System.Diagnostics.EventLog.SourceExists(LOG_SOURCE)) Then
EventLog.DeleteEventSource(LOG_SOURCE)
End If

If System.Diagnostics.EventLog.Exists(LOG_NAME) Then
System.Diagnostics.EventLog.Delete(LOG_NAME)
End If

If (Not System.Diagnostics.EventLog.SourceExists(LOG_SOURCE)) Then
EventLog.CreateEventSource(LOG_SOURCE, LOG_NAME)
End If

el = New EventLog(LOG_NAME)
el.Log = LOG_NAME
el.Source = LOG_SOURCE

el.WriteEntry(LOG_SOURCE, "LogWorker succeeded in writing to
ServOneLog.")

End Sub


End Module
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top