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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Writing to the NT Event Log using VB

Status
Not open for further replies.

jmorgan

Programmer
Mar 16, 2001
9
US
I'd like to write to the NT Event Log as part of my error handling routine so that another program that monitors the log can notify the appropriate people of the error. The monitoring/notification piece is already in place. My task is only to write to the log. Any suggestions on how to accomplish this?
Thanks,
Jess
 
Am I the first to answer my own question? In any case... the solution is simple:

Call App.StartLogging("", vbLogToNT)

'-- Log Events to NT
Call App.LogEvent("Info", vbLogEventTypeInformation)
Call App.LogEvent("Error", vbLogEventTypeError)
Call App.LogEvent("Warning", vbLogEventTypeWarning)
 
Yes, that will work. Be advised however, the event logging will not work while code is running in debug mode (within the IDE). It will only log correctly when the compiled binary is running. - Jeff Marler B-)
 
Yep, know about that and it's not really a problem. My app is up and running now. Thanks!
 
JMorgan -

Be advised that the NT event log can fill up if you write a ton of data to it.

A better solution (especially if your app runs on a web server farm) is to write to a database. That way you can log which machine the error came from, plus be able to view the log remotely via a mini web-app.

Chip H.
 
Chip is correct here . . .If you have a small amount of messages (perhaps critical errors) can be written to the event log, but if you are going to be writing a large amount of information, use a DB. - Jeff Marler B-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top