Eventlog questions

  • Thread starter Thread starter Crea-Ue. Kirdar
  • Start date Start date
C

Crea-Ue. Kirdar

hi there,

i am out of ideas what to do with that eventlog-things. it seems,
that the implementation of the eventlog-support in dotnet is really
poor. however, here are the problems i have at the moment:

- if i ask for the id of an event i do not get the number that is
displayed in the eventviewer for messages with replacement-strings.

- if i ask for the message of an event with replacement-strings, i get
the message with "unable to format message...".

does anyone of you have an idea of how to solve that problems?

i'd appreciate any help.

thanks,

crea
 
dd said:
I must see your code before answering.

hi dd,

here it comes:

public static void WriteEvents(string Machine, string Log, string DisplayFormat)
{
EventLog Reader=null;
Reader=new EventLog(Log, Machine);

foreach (EventLogEntry Entry in Reader.Entries)
{
Console.WriteLine("***");
Console.WriteLine("Type : " + Entry.EntryType.ToString());
Console.WriteLine("Date : " + Entry.TimeGenerated.ToShortDateString());
Console.WriteLine("Time : " + Entry.TimeGenerated.ToLongTimeString());
Console.WriteLine("Source : " + Entry.Source.ToString());
Console.WriteLine("Category : " + ((Entry.CategoryNumber==0)?"none":Entry.Category.ToString()));
Console.WriteLine("EventID : " + Entry.EventID.ToString());
Console.WriteLine("User : " + ((Entry.UserName==null)?"none":Entry.UserName.ToString()));
Console.WriteLine("Machine : " + Entry.MachineName.ToString());
Console.WriteLine("Message : " + Entry.Message.ToString().Replace("\n", "-").Replace("\r", "-"));
}
}

nothing unusual, as you can see. its just querying the eventlog.

cheers,

crea
 
Maybe, I just did not understand your problem.
When I ran your code, it prints everything identical to my EventLog.
EventId's are the same as in the EventLog.
Did you get errors while running your code, or you are trying to accomplish
something else?
 

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

Back
Top