HELP! - App.LogEvent Not Writing to EventLog

HELP! - App.LogEvent Not Writing to EventLog

Post by Joseph Ger » Sat, 22 Nov 2003 08:08:33


I've got the following two statements inside a class method which is
internal to an EXE.

App.LogEvent "BEGIN SQL: " & sSQLCommand
...
App.LogEvent "END SQL: " & sSQLCommand

I know these lines are executed since I've placed breakpoints on them. Yet
nothing shows up in the EventLog!?.

I'm baffled.

VB6 running in IDE on Win2K Professional.

Thanks for your help!

- Joe Geretz -
 
 
 

HELP! - App.LogEvent Not Writing to EventLog

Post by Joseph Ger » Sat, 22 Nov 2003 08:14:18

Oops, sorry. I forgot that this only works for compiled Apps. You can tell
how long my head has been out of this environment...

- Joe Geretz -

 
 
 

HELP! - App.LogEvent Not Writing to EventLog

Post by Ken Halte » Sat, 22 Nov 2003 08:18:50

Help on that method isn't the best... but if you look up LogPath (highlight the word
LogEvent in your code window and hit F1... then select "See Also" and choose LogPath),
you'll see that LogEvent only works in a compiled program. Not from within the IDE. Even
then, it's limited. A bit more work'll give you a lot better output...

See:

Read/Write to Event log samples....
http://www.yqcomputer.com/

--
Ken Halter - MS-MVP-VB - http://www.yqcomputer.com/
Please keep it in the groups..
 
 
 

HELP! - App.LogEvent Not Writing to EventLog

Post by dnage » Sat, 22 Nov 2003 08:25:41

this code wrote to my eventlog just fine...

Option Explicit

Private Sub Form_Load()
App.StartLogging "", 3
App.LogEvent "What to log??? that is the question", 1
App.LogEvent "What to log??? that is the question", 2
App.LogEvent "What to log??? that is the question", 4
End Sub

The events are ONLY written from the EXE, never from within the IDE...

Also, don't count on the constants used in the help files to
identify the correct parameter values... they don't work for some
reason??? use the actual numbers...

hth,

D.
 
 
 

HELP! - App.LogEvent Not Writing to EventLog

Post by Pztor, Zol » Sat, 22 Nov 2003 20:41:27

Hi dnagel,

can you tell me what's wrong with the symbolic constants for LogEvent (or
StartLogging)?
They seem OK on my system (VB6SP5).

And another question: I remember having read that StartLogging is not needed
for W2K, but cannot find it in the Help. Is this true? And is StartLogging
required for NT, or is vbAutoLog the default setting there, too?

Thank you,
 
 
 

HELP! - App.LogEvent Not Writing to EventLog

Post by Joe "Nuke » Sat, 22 Nov 2003 23:20:22


In VB5, the logging constants are missing, so I had to roll my own:

Public Enum EventType
vbLogEventTypeError = 1
vbLogEventTypeWarning = 2
vbLogEventTypeInformation = 4
End Enum

Public Enum LogModes
vbLogAuto
vbLogOff
vbLogToFile
vbLogToNT
vbLogOverwrite = &H10
vbLogThreadID = &H20
End Enum


The default in NT is to spew to the event log. While it's possible
to redirect to a file using vbLogToFile, the formatting is useless.
The formatting of the event log entries is all but useless as well!
 
 
 

HELP! - App.LogEvent Not Writing to EventLog

Post by Pztor, Zol » Sun, 23 Nov 2003 01:27:04

Thank you.