Writing a simple text message to the eventlog


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: Writing a simple text message to the eventlog

  1. #1
    Murray Foxcroft Guest

    Writing a simple text message to the eventlog

    Hi all - I'm not sure where I should be posting this,
    but I'm trying to (using vc++ 6) write to the event
    log. Just a simple error entry. I am a newbie and
    dont even know where to start.

    Any help / samples / ideas greatly appreciated.

    Thanks in advance




  2. #2
    Igor Soukhov Guest

    Re: Writing a simple text message to the eventlog


    "Murray Foxcroft" <murrayf@ebit.co.za> wrote:
    >Hi all - I'm not sure where I should be posting this,

    Hi !

    You can use ofstream object to write log data to file.
    Here's the little example:

    #include <fstream>
    #include <iomanip>
    using namespace std;

    int main()
    {
    //doing something ... 1

    //write string to log
    AddStringToEventLog("Phase 1 completed");

    //doing something ... 2

    //write string to log
    AddStringToEventLog("Phase 3 completed");

    //...

    AddStringToEventLog("Programm successfully completed");
    return 1;
    };

    void AddStringToEventLog(string const & strEntry)
    {
    static ofstream eventlogfile("EventLogFile.TXT");
    eventlogfile << strEntry << endl;
    }


    >but I'm trying to (using vc++ 6) write to the event
    >log. Just a simple error entry. I am a newbie and
    >dont even know where to start.



    >Any help / samples / ideas greatly appreciated.
    >Thanks in advance









  3. #3
    a Guest

    Re: Writing a simple text message to the eventlog


    http://msdn.microsoft.com/library/de...ntlog_8btz.asp

    "Igor Soukhov" <igor@soukhov.com> wrote:
    >
    >"Murray Foxcroft" <murrayf@ebit.co.za> wrote:
    >>Hi all - I'm not sure where I should be posting this,

    >Hi !
    >
    > You can use ofstream object to write log data to file.
    >Here's the little example:
    >
    >#include <fstream>
    >#include <iomanip>
    >using namespace std;
    >
    >int main()
    >{
    > //doing something ... 1
    >
    > //write string to log
    > AddStringToEventLog("Phase 1 completed");
    >
    > //doing something ... 2
    >
    > //write string to log
    > AddStringToEventLog("Phase 3 completed");
    >
    > //...
    >
    > AddStringToEventLog("Programm successfully completed");
    > return 1;
    >};
    >
    >void AddStringToEventLog(string const & strEntry)
    >{
    > static ofstream eventlogfile("EventLogFile.TXT");
    > eventlogfile << strEntry << endl;
    >}
    >
    >
    >>but I'm trying to (using vc++ 6) write to the event
    >>log. Just a simple error entry. I am a newbie and
    >>dont even know where to start.

    >
    >
    >>Any help / samples / ideas greatly appreciated.
    >>Thanks in advance

    >
    >
    >
    >
    >
    >
    >



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center