Consultor Eletrônico



Kbase P184333: How to write a multi-line event to the event log using .NET class in ABL
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   17/03/2011
Status: Unverified

GOAL:

How to write a multi-line event to the event log using .NET class in ABL

GOAL:

Can I use the .NET System.Diagnostics.EventLog class to log multiple lines of data to the event log?

FACT(s) (Environment):

OpenEdge 10.2x
Windows

FIX:

The following sample code shows how to use the .NET System.Diagnostics.EventLog class to write multiple lines of data to the event log. Please note that on Windows XP only the first line of data will be shown in the event log.

using System.*.
using System.Diagnostics.*.

define variable cSource as character no-undo initial "SomeSource".
define variable cLog as character no-undo initial "SomeApplication".
define variable cMachine as character no-undo initial "SomeMachine".
define variable cEventData as character no-undo extent 2.

define variable oEventInstance as EventInstance no-undo.
define variable rValues as "System.Object[]" no-undo.
define variable oEventLog as EventLog no-undo.

if not EventLog:SourceExists(cSource,cMachine) then
EventLog:CreateEventSource(cSource,cLog,cMachine).

oEventLog = new EventLog (cLog, cMachine, cSource).

oEventInstance = new EventInstance (0, 0, EventLogEntryType:Information ).

cEventData[1] = "Line #1".
cEventData[2] = "Line #2".

rValues = new "System.Object[]" (2).

rValues:SetValue(cEventData[1], 0).
rValues:SetValue(cEventData[2], 1).

oEventLog:WriteEvent(oEventInstance,rValues).

finally:
delete object oEventLog.
delete object rValues.
end finally.