B
Bill Ward
I have a suite of applications and services that use a common library and I
would like to use a custom event log to gather all the events in one place
rather than putting events in the "Application" event log. The code I use to
create the event log object is below. Clearly I'm missing some steps because
the results are not correct. A new event log called EJobs is created but is
never populated with events. All event log mesages still go into the
Application event log but are not displayed correctly. In the event viewer a
typical entry looks like this...
The description for Event ID ( 0 ) in Source ( MyNewService ) 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:
Registering service types.
If I create the EventLog object to write into the Application log, then
everything works properly and you only see the intended text rather than the
text about needing to use AUXSOURCE as well.
Any suggestions would be gratefully received.
Thanks
Bill
public abstract class EJobEventLog
{
private const string EventLogName = @"EJobs";
// private const string EventLogName = @"Application";
/// <summary>
/// Create an event log object.
/// </summary>
/// <param name="strEventSourceName">The name to use for the source of
the new event log.
/// Typically this is the name of the calling application or
service.</param>
/// <returns>New <see cref="EventLog"/> object</returns>
public static EventLog CreateEJobEventLog(string strEventSourceName)
{
EventLog.DeleteEventSource(strEventSourceName, @".");
if (!EventLog.SourceExists(strEventSourceName, @"."))
{
EventSourceCreationData oSource =
new EventSourceCreationData(strEventSourceName,
EventLogName);
EventLog.CreateEventSource(oSource);
}
return new EventLog(EventLogName, @".", strEventSourceName);
}
}
would like to use a custom event log to gather all the events in one place
rather than putting events in the "Application" event log. The code I use to
create the event log object is below. Clearly I'm missing some steps because
the results are not correct. A new event log called EJobs is created but is
never populated with events. All event log mesages still go into the
Application event log but are not displayed correctly. In the event viewer a
typical entry looks like this...
The description for Event ID ( 0 ) in Source ( MyNewService ) 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:
Registering service types.
If I create the EventLog object to write into the Application log, then
everything works properly and you only see the intended text rather than the
text about needing to use AUXSOURCE as well.
Any suggestions would be gratefully received.
Thanks
Bill
public abstract class EJobEventLog
{
private const string EventLogName = @"EJobs";
// private const string EventLogName = @"Application";
/// <summary>
/// Create an event log object.
/// </summary>
/// <param name="strEventSourceName">The name to use for the source of
the new event log.
/// Typically this is the name of the calling application or
service.</param>
/// <returns>New <see cref="EventLog"/> object</returns>
public static EventLog CreateEJobEventLog(string strEventSourceName)
{
EventLog.DeleteEventSource(strEventSourceName, @".");
if (!EventLog.SourceExists(strEventSourceName, @"."))
{
EventSourceCreationData oSource =
new EventSourceCreationData(strEventSourceName,
EventLogName);
EventLog.CreateEventSource(oSource);
}
return new EventLog(EventLogName, @".", strEventSourceName);
}
}