Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to read and write to the Windows Event Log

Status
Not open for further replies.

NegreteO

Programmer
Apr 23, 2003
54
US
Hi

I want to log errors into the Windows Event Log (Applicaction Section) and also get this errors according to a certain category

Hope you can help me
Thanks
 
To use the app logging I do the following,

To start logging to a file:
App.StartLogging <path to file>, vbLogToFile

To send information to the file:
App.LogEvent Message, vbLogEventTypeInformation
or
App.LogEvent Message, vbLogEventTypeError

To stop thye logging:
App.StartLogging <path to file>, vbLogOff

You can also log to the NT log event and I beleive a couple of other places, Just change the contant when you start logging.

Remember that this will only work outside the VB IDE. So if you run your project from VB no error logging will be done. Create the exe and run it outside Vb to see the logging.

Thanks and Good Luck!

zemp
 
NegreteO

The writing to the log has been covered by zemp and robctech. There is more to it than that, but they have covered the stuff you can use without getting deep into API world.

Reading the event log is a real pain, but if you wish to do it I suggest strongm's proof on concept code as a starter. Its link thread222-395506

Take Care

Matt
If at first you don't succeed, skydiving is not for you.
 
Reading the windows event log is complicated. I took the easy way out. I log or write the errors or events that I want to log to a text file and then use shell to open notepad and I can view the &quot;log file&quot;.

I also use this for programs run by clients so that they can easily email me the log file if they are having problems.

Thanks and Good Luck!

zemp
 
Phew - well done Matt, I couldn't find the thread and thought I might have to repost...
 
>I couldn't find the thread

Oh for a search engine that searched!

Take Care

Matt
If at first you don't succeed, skydiving is not for you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top