J
JimM
I think I am missing something and hopefully someone can set me straight.
I am trying to create an event log with the logName and source arguments.
The logName is always set to MyLog. The source is set to one of several
names, for example: MySource1 and MySource2. I want all the messages to be
in the MyLog folder of the Event Viewer with the source changing by the
application writing the event entry.
Now to create the event log entry I use either the deployment
PojectInstaller class or the EventLog.CreateEventSource method. Both of
these methods get the MyLog folder in the event viewer.
For this example I will use the create method. So the create statements for
both Applications are:
MySource1 application:
EventLog.CreateEventSource( “MySource1â€, “MyLogâ€, “.†);
MySource2 application:
EventLog.CreateEventSource( “MySource2â€, “MyLogâ€, “.†);
After the appropriate programs execute these statements I see the MyLog
folder along with the Application, Security, and System folders. Ok
everything is as expected.
Now I write an event entry using the MySource1 as the source. Then I write
another event for the MySource2. I want both entries in the MyLog folder
when I look in the event viewer.
I use the following statements to write the event entry and I change the
sourceName variable to either MySource1 or MySource2 depending on the
application.
My write code looks like:
Using( EventLog eventLog = new EventLog( “MyLogâ€, “.â€, sourceName )
{
try
{
eventLog.WriteEntry( “My message†);
}
catch( Exception ex )
{
:
}
try
{
eventLog.Close(); // make sure all is flushed to the log.
}
catch( Exception ex )
{
:
}
}
This works as expected and entry is written, but not to the expected folder.
The problem is if I write the MySource1 followed by the MySource2 I see the
MySource1 in the MyLog folder, but the MySource2 is in the Application
folder. The MySource2 always seems to go to the Application folder. What is
going on? If the logName is MyLog the WriteEntry should only write to the
MyLog folder.
I am trying to create an event log with the logName and source arguments.
The logName is always set to MyLog. The source is set to one of several
names, for example: MySource1 and MySource2. I want all the messages to be
in the MyLog folder of the Event Viewer with the source changing by the
application writing the event entry.
Now to create the event log entry I use either the deployment
PojectInstaller class or the EventLog.CreateEventSource method. Both of
these methods get the MyLog folder in the event viewer.
For this example I will use the create method. So the create statements for
both Applications are:
MySource1 application:
EventLog.CreateEventSource( “MySource1â€, “MyLogâ€, “.†);
MySource2 application:
EventLog.CreateEventSource( “MySource2â€, “MyLogâ€, “.†);
After the appropriate programs execute these statements I see the MyLog
folder along with the Application, Security, and System folders. Ok
everything is as expected.
Now I write an event entry using the MySource1 as the source. Then I write
another event for the MySource2. I want both entries in the MyLog folder
when I look in the event viewer.
I use the following statements to write the event entry and I change the
sourceName variable to either MySource1 or MySource2 depending on the
application.
My write code looks like:
Using( EventLog eventLog = new EventLog( “MyLogâ€, “.â€, sourceName )
{
try
{
eventLog.WriteEntry( “My message†);
}
catch( Exception ex )
{
:
}
try
{
eventLog.Close(); // make sure all is flushed to the log.
}
catch( Exception ex )
{
:
}
}
This works as expected and entry is written, but not to the expected folder.
The problem is if I write the MySource1 followed by the MySource2 I see the
MySource1 in the MyLog folder, but the MySource2 is in the Application
folder. The MySource2 always seems to go to the Application folder. What is
going on? If the logName is MyLog the WriteEntry should only write to the
MyLog folder.