Event Logging in Visual Basic 6

This is old-school, but you may be on a project requiring you to work in VB6 (Jay). You can log events to the NT event log by invoking the LogEvent method on the App object.

VB6 - LogEvent Method
http://msdn.microsoft.com/library/en-us/vb98/html/vbmthLogEventMethod.asp

It turns out you can only log events from a compiled application. It won't work if you're running your application from the VB6 environment for debugging purposes. The following article suggests creating an ActiveX DLL to hold the logging function.

INFO: App.LogEvent Only Logs in Compiled Applications
http://support.microsoft.com/default.aspx?scid=kb;en-us;161306

However, this won't work in ASP without some Registry modifications. I don't know about ASP.NET, but again this is old-school.

PRB: App.Logevent Does Not Work in Components that You Call from ASP on Windows 2000
http://support.microsoft.com/default.aspx?scid=kb;en-us;251264

There is a lengthy article devoted to ASP logging.

How To Log Events from Active Server Pages
http://support.microsoft.com/default.aspx?scid=kb;en-us;301309

You can also log events to your own file by invoking the StartLogging method on the App object.

VB6 - StartLogging Method
http://msdn.microsoft.com/library/en-us/vb98/html/vbmthstartloggingmethod.asp

Event logging is available in several contexts. I'm sure everyone knows how to do it in .NET (and now from VB6), but you can also do it from script.

Windows Script Host - LogEvent Method
http://msdn.microsoft.com/library/en-us/script56/html/wsmthlogevent.asp

Here is the search I used to find out all of this information.

MSDN search for LogEvent
http://search.microsoft.com/search/results.aspx?View=msdn&st=a&qu=LogEvent&c=0&s=1

posted on Thursday, May 26, 2005 1:41 PM by Chris

Comments