LOG statement

Use the LOG statement to write a record to the event log or to the user trace.

Syntax

Read syntax diagramSkip visual syntax diagramLOG EVENTUSERTRACE FULLEXCEPTION Options VALUES(,Expression)
WHERE
Read syntax diagramSkip visual syntax diagramOptions = SEVERITYExpression CATALOGExpression MESSAGEExpression
CATALOG
CATALOG is an optional clause; if you omit it, CATALOG defaults to the IBM® Integration Bus current version catalog. To use the current version message catalog explicitly, use BIPmsgs on all operating systems.
EVENT
A record is written to the event log, and also to the user trace, if user tracing is enabled.
EXCEPTION
The current exception, if any, is logged.

For more information on exceptions, see Errors and exception handling.

FULL
The complete nested exception report is logged, just as if the exception had reached the input node. If FULL is not specified, any wrapping exceptions are ignored, and only the original exception is logged. Therefore, you can have either a full report or simply the actual error report without the extra information regarding what was going on at the time. A current exception only exists within handler blocks (see Handling errors in message flows).
MESSAGE
The number of the message to be used. If specified, the MESSAGE clause can contain any expression that returns a non-NULL, integer, value.

If you omit MESSAGE, its value defaults to the first message number (2951) in a block of messages that is provided for use by the LOG and THROW statements in the IBM Integration Bus catalog. If you specify a message number, you can use message numbers 2951 through 2999. Alternatively, you can generate your own catalog.

SEVERITY
The severity associated with the message. If specified, the SEVERITY clause can contain any expression that returns a non-NULL, integer, value. If you omit the clause, its value defaults to 1.
  • SEVERITY 1 The default value. Writes information messages.
  • SEVERITY 2 Writes Warning messages.
  • SEVERITY 3 Writes Error messages.
USER TRACE
A record is written to the user trace, whether user trace is enabled or not.
VALUES
Use the optional VALUES clause to provide values for the data inserts in your message. You can insert any number of pieces of information, but the messages supplied (2951 - 2999) cater for a maximum of ten data inserts.

Note the general similarity of the LOG statement to the THROW statement.

  -- Write a message to the event log specifying the severity, catalog and message
  -- number. Four inserts are provided
  LOG EVENT SEVERITY 1 CATALOG 'BIPmsgs' MESSAGE 2951 VALUES(1,2,3,4);

  -- Write to the trace log whenever a divide by zero occurs
  BEGIN
    DECLARE a INT 42;
    DECLARE b INT 0;
    DECLARE r INT;

    BEGIN
      DECLARE EXIT HANDLER FOR SQLSTATE LIKE 'S22012' BEGIN
        LOG USER TRACE EXCEPTION VALUES(SQLSTATE, 'DivideByZero');

        SET r = 0x7FFFFFFFFFFFFFFFF;
      END;

      SET r = a / b;
    END;

    SET OutputRoot.XMLNS.Data.Result = r;
  END;