Skip to main content

Enabling CSP Logging

This page describes how to enable logging that records CSP activity, which is useful for troubleshooting CSP-based web applications.

Enabling and Disabling Logging

Enable logging by entering the following command in the ObjectScript shell:

 Set ^%ISCLOG = 2

Also see Log Levels.

You can turn logging off as follows:

 Set ^%ISCLOG = 0

Log Levels and Filtering by Tag

For reference, the log levels are as follows:

  • 0 — InterSystems IRIS® data platform performs no logging.

  • 1 — InterSystems IRIS logs only exceptional events (such as error messages).

  • 2 — InterSystems IRIS also logs detailed information, such as method ABC invoked with parameters X,Y,Z and returned 1234.

  • 3 — InterSystems IRIS also logs raw information such as data received from an HTTP request.

    Note that you need log level 3 to obtain information on the part of request handling that up the %response, %session, and %request variables and that shows the data transfer with the Web Gateway.

  • 5 — InterSystems IRIS also logs OAuth 2.0 information.

Also, InterSystems IRIS provides a flexible mechanism that controls which ^%ISCLOG entries are generated, for the case when a more granular approach is needed but you want to keep the log size from becoming too large. This mechanism works as follows:

  • Entries in the log include the Tag field; see CSP Log Details.

  • When setting the log level, you can also specify which tags to log, as in the following example:

     Set ^%ISCLOG("Tag","mytagvalue1")=1
     Set ^%ISCLOG("Tag","mytagvalue2")=1
    

    In this example, only log entries with no tag or with tags of mytagvalue1 or mytagvalue2 will be recorded.

This mechanism works in conjunction with the log levels.

Viewing the Log

When CSP logging is enabled, InterSystems IRIS writes to the ^ISCLOG global in the %SYS namespace; which is available via SQL as the table %Library.SysLogTableOpens in a new tab. (You can use ZWRITE to display the global, but the details are easier to read when you query the table.) To view the log in the Management Portal:

  1. Click System Explorer > SQL.

  2. On the Execute Query tab, enter a query like the following:

    SELECT 
    ID, Category, LogLevel, Namespace, Pid, Routine, SessionId, Tag, TimeAdded, Message
    FROM %Library.SysLogTable
  3. Click Execute.

Fields in the Log

The fields in the table %Library.SysLogTableOpens in a new tab are as follows:

ID

Indicates the unique record ID of a field in this table.

Category

This field is meant to categorize the records roughly by which part of processing the log came from. The categories include the following:

  • CSPBroker

  • CSPLicense—The item was logged from the parts of cspServer and cspServer2 that handle licensing.

  • CSPResponse

  • CSPServer—The item was logged from one of the following: cspServer, cspServer2, %request, %response

  • CSPSession—The item was logged from %session or parts of cspServer and cspServer2 which handle a session. This allows watching the lifecycle of a session.

  • CSPStream

  • GatewayRegistry

  • GatewayRequest—The item was logged from the GatewayMgr, GatewayRegistry, the web Gateway request handler, or the parts of cspServer2 that handle web Gateway requests.

  • OutputRedirection

  • SuperServer

LogLevel

Indicates the log level that is responsible for this log entry.

Message

Indicates the actual message. See Message Format.

Namespace

Indicates the namespace from which this log entry was added.

Pid

Indicates the ID of the process that added this log entry. (This is the same as Cache-PID in the Event Log.)

Routine

Indicates the routine that added this log entry.

SessionId

Indicates the ID of the CSP session from which this log entry was added. (This is the same as Session-ID in the Event Log.)

Tag

This field is meant to support filtering of the log. For the CSP Server, the Tag contains the Request id from the web Gateway (when available). (This is the same as Request-ID in the Event Log.) Other loggers may set this value to any value; that is, this option is available for use by creators of ^%ISCLOG entries.

TimeAdded

Indicates the date and time when this log entry was added.

Details of the Message Field

In the CSP log, entries in the Message field start with the name of the tag label or method currently being executed. This name is enclosed in square brackets. [MyMethod] rest of messages.

Messages in the CSPSession category also have CSPSession-Id=sessid after the method name. This is needed as session events can be logged before the session is created or after it was destroyed, meaning the SessionId field is empty in the log.

[MyMethod] CSPSession-Id: 12ty34ui22

Messages in the GatewayRegistry category also have CSPID=cspid(when available) after the method name. This allows the tracking of an individual gateway request from the API call through the Gateway Request Handler.

 [MyMethod]CSPID:334r43345 rest of message

Clearing the Log

To clear the entire log, enter the following command in the %SYS namespace:

 kill ^ISCLOG
FeedbackOpens in a new tab