guides:oi10:presentation_server:logevent_method_system

LOGEVENT Method (System)

This method writes a message to the Windows Event Log.

 
IsLogged = Exec_Method( "SYSTEM", "LOGEVENT", TypeInfo, SourceInfo, 

                           MessageText )
 
NameRequiredDescription
TypeInfoSee
Description
An @fm delimited array containing the following fields:

<1> Message Type (Required): Must be one of the

following values:



"ERROR"

"WARNING"

"INFO"



<2> Event ID (Optional): Integer denoting the event.

Defaults to 1.



<3> Category ID (Optional) Integer identifying the

category. Defaults to 0.
SourceInfoSee
Description
An @fm delimited array containing the following fields:



<1> Event Source (Required): Name of the Event Source

(See notes on the Event Source below for more

details).



<2> Server Name (Optional): UNC name of the system to

Post the message to. Defaults to the local

Workstation.
MessageTextYesMessage to write to the Event Log.

TRUE$ if the message is logged successfully, FALSE$ otherwise.

This method is essentially a wrapper around the Windows API ReportEvent and other Event Log related functions – for further information please see the MSDN website.

 
// Example – Log a FOOBAR error message for RevPS in the Windows Event Log 

   

   IsLogged = Exec_Method( "SYSTEM", "LOGEVENT", "ERROR", "RevPS", "FOOBAR!!!!" )

The Event Source

If the above example is executed the message will be displayed in the Application Event Log, but Windows will prefix the message with some of its own text which refers to a missing Event ID description like so:

The reason for this is that Windows expects to find a “registered Event Source” containing the description for the Event ID that was specified. A registered Event Source is actually a DLL containing a set of strings, each of which corresponds to an Event ID. Without this DLL the warning text displayed above is prefixed, which could give the impression that something is missing from the application.

To avoid this OpenInsight provides a generic DLL called RevEventMsg.dll that can be registered on a workstation system under the desired Event Source name – if that name is then used in a LOGEVENT call the message will be logged without any of the warning text prefixed to it.

Registering the DLL is quite simple: create a new key with the name of the Event Source (The string “RevPS” was used for this example) under this path:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\eventlog\Application\

And then set the following values:

If the message is logged again the text is no longer prefixed:

N/A

  • guides/oi10/presentation_server/logevent_method_system.txt
  • Last modified: 2023/10/25 10:49
  • by 127.0.0.1