Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

How do I make entries in the Application log file

PeterGillhamPeterGillham Member Posts: 1
I have a .Net VC++ application and I want to add loggin to the Applications log file ( WinNT & Win2K etc ).
I've looked arounbd and cant seem to find hoe to do it.
It must be somewhere, can anyone help ?

Comments

  • rwbean86rwbean86 Member Posts: 7
    : I have a .Net VC++ application and I want to add loggin to the Applications log file ( WinNT & Win2K etc ).
    : I've looked arounbd and cant seem to find hoe to do it.
    : It must be somewhere, can anyone help ?
    :


    I guess you are trying to work with the Eventviewer? Here's some code I wrote that does it in C#. It shouldn't be hard to port to managed c++. Hope this helps.
    .
    .
    .
    using System.Diagnostics;//for custom error log
    .
    .
    .
    //Create a log object
    private EventLog m_PrntErrLog = new EventLog();
    .
    .
    .
    //You would specify "Application Log" instead of "FingerPrintErr"
    //init Error log
    m_PrntErrLog.Log = "FingerPrintErr";
    //Put the name of your app/process instead of "PrintBase"...
    //this will show up in the log
    m_PrntErrLog.Source = "PrintBase";
    .
    .
    .
    //When a user logs in create a string with the applicable info.
    string ErrStr = "ERROR READING PIXEL DATA FROM FILE " m_PrntErrLog.WriteEntry(ErrStr);
    .
    .
    .
    //When you're finished with the log...
    m_PrntErrLog.Close();

    There is a good example in Andrew Troelson's C# book. You can download the sample from the wintellect web site. Unzip the code and look at the FinalFormsApp under chapter8 subdir.
Sign In or Register to comment.