EventLog in C#

Hi ,

I wanted to write messages to windows eventlog . I will read messages from certain file say xyz. What my question is , is there any possiblity to write date and time which i read it from xyz file to eventlog along with other parameters such as source , event id , message etc.

Thank you guys for looking into this.

Regards,

Prasanna.




Answer this question

EventLog in C#

  • Bob2unlimited

    The System.Diagnostics.EventLog class might be useful. Start reading here...



  • Yassir Zoheiri

    Thats very smart....Thank you .



  • Devin G

    I think the date/time stamp is automatically generated. If you need to log an event with a different time stamp, just put it in the message string.



  • orourksj

     

    Ya i finished up using  EventLog class of FrameWork . I am able write messages into EventLog but my actual question is would it be able to write date and time along with other parameters such as source , event id and message. Because i see WriteEntry of EventLog is being overloaded with different parameters but i didnt see any overloaded version of WriteEntry which takes date and time as parameter.

    Thank you very much for looking into the case.



  • farang

    Here is a code sample:

    using System.Diagnostics;

    EventLog el = new EventLog();
    el.Source = "AdoDisconnectedApp";

    el.WriteEntry("Hello", EventLogEntryType.Error);

    Check out the Microsoft Wiki on it.


  • EventLog in C#