Documentation Center

Using Event Monitor for logging

Event Monitor allows central logging in the database, allowing any client to follow-up and possibly retrieve status of their events. Although Event Monitor can be used to log all kinds of information, the logging is mainly used for grouping the logging of background tasks.

Introduction

An overview of the steps necessary to insert the logging (of a background task) into Event Monitor is provided. To begin, a focus on the flow of the asynchronous processes is described.

Each background task has 2 parts which have a slightly different usage of Event Monitor:
  • The synchronous part where all necessary information is collected. This information is sent as event data to the asynchronous part.
  • The asynchronous part receives the event data and uses this to perform the background task

Synchronous part

Logging information into Event Monitor from within the synchronous part involves 3 steps:
  1. Initialize the event

    Before you can log anything into Event Monitor, you always have to initialize your event using StartEvent.

  2. Log information

    When the event is initialized, you can start logging information into the event using AddEventDetail.

  3. Error handling

    If the event is initialized and an exception occurs, the event must be closed before leaving the method. If the event is not closed, the event will remain BUSY

    First log the exception and all necessary information about the exception into Event Monitor using AddEventDetail. Then close the event using EndEvent.

Asynchronous part

Logging information into Event Monitor from within the asynchronous part involves 4 steps:
  1. Get the unique identifier of the event

    • Normally the event is initialized in the synchronous part and the asynchronous part gets an EventId. Before starting to log information into Event Monitor, the EventId must be converted into the ProgressId using the method GetProgressId.
    • If the event is not yet initialized, you can start the event in the asynchronous part using StartEvent.
  2. Log information

    When you have the unique identifier of the event, you can add extra information to the event.

    There are 2 methods available for logging information into Event Monitor:
    • AddEventDetail which can be used for logging extra information
    • If you not only want to log information but you also want to update the progress information (current or maximum) , you can use AddEventDetailWithProgress . For performance reasons, you should NOT use this method if you don't want to update the progress information.
  3. Close the event

    At the end of the asynchronous part the event must be closed using EndEvent

  4. Error handling

    If the event is initialized and an exception occurs, the event must be closed before leaving the method. If the event is not closed, the event will remain BUSY.

    First log the exception and all necessary information about the exception into Event Monitor using AddEventDetail. Then close the event using EndEvent.

Remarks
  • All methods in the Event Monitor Web Services throw an exception when an error occurs. If you don't want your (background) process to fail because the logging throws an error, you should make a wrapper method to catch and handle the exceptions of Event Monitor.