how to write to Applicaton log

J

John Grandy

Is the following the correct code to write to the Application EventLog :

EventLog appLog = new EventLog();

appLog.Source = String.Empty;

appLog.WriteEntry("my message");
 
F

Francois Bonin [MVP]

No it's not. You need to give a non-null non-empty value to the Source
property of your EventLog object.
 
J

John Grandy

Hi Francois, and thanks for the response.

Ok, I've figured out most of what I need to do from the documentation ...
except for how to specify the different types of log-entries: Information,
Warning and Error

EventLog does not seem to have an appropriate property.
 
B

Brendan Green

WriteEntry has an overload (as mentioned in the documentation):

appLog.WriteEntry("my message", EventLogEntryType.Warning);
 

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

Top