logging (logging options)

logging (logging options)

This setting was added in Profound.js 7.6.0.

When using this option to write stdout/stderr log files from within the process (the default) and starting the instance with STRTCPSVR on IBM i, set the STRTCPSVR instance configuration option logging=0 to avoid duplicate log files.

Description

This option controls logging and log file rotation for every log file that Profound.js writes. It replaces the individual accessLog, accessLogFormat, and accessLogRotation options.

Log Types

The top-level keys correspond to the log files written by Profound.js:

  • stdout - Process standard output. This includes the output of calls to console.log() and process.stdout.write();

  • stderr - Process standard error. This includes the output of calls to console.error() and process.stderr.write();

  • access - HTTP request log. Includes one line of output for each HTTP request handled by the server, similar in concept to an Apache HTTP server access log;

  • license - Profound.js license log. Includes output relating to floating license seat activation and deactivation (see Floating Licenses);

  • ai_chat - Profound AI chat log. Records conversations with any and all Profound AI agents;

  • sessions - Records an entry for each Rich Display File application session start and end, along with the associated IBM i job details;

  • atrium_proxy - Atrium proxy log. This log is opt-in and is disabled by default.

Options for Each Log Type

Each top-level key can be set to an object that controls the options for that log type:

  • enabled - Set to false to disable the log. For stdout and stderr, disabling only turns off writing log files from within the Profound.js process; output is still written to the process’s stdout/stderr streams and remains visible to the controlling process – a process manager, terminal window, VS Code debug console, and so on;

  • interval - The interval at which to rotate log files. Must be a string containing a positive integer followed by one of these suffixes:

    • s - seconds;

    • m - minutes;

    • h - hours;

    • d - days.

  • maxFiles - Maximum number of rotated files to retain. A positive integer, or null for no maximum;

  • maxSize - Maximum size of rotated files to retain. Set to null for no maximum, or to a string containing a positive integer followed by one of these suffixes:

    • B - bytes;

    • K - kilobytes;

    • M - megabytes;

    • G - gigabytes.

  • compress - Set to true to compress rotated files;

  • timestamp - When true, all log entries are prefixed with a UTC timestamp taken at the time the entry is written. Some log types – such as access and ai_chat – embed timestamps in the entries themselves, so this option may conflict with them;

  • sessionId - When true, all log entries are prefixed with a session id following the timestamp, if any. Entries that do not pertain to a session show a hyphen in place of the session id. Some log types, such as ai_chat, embed session ids in the entries themselves, so this option may conflict with them;

  • opts - Options specific to an individual log type:

    • For the access log, format sets the log format string for the underlying access logger package, morgan.

Log files are written to the directory specified by the logDirectory configuration option.

Default Value

logging: { stdout: { enabled: true, interval: "1d", // Rotate the file at every midnight. maxFiles: 7, // Keep 7 rotated files. maxSize: "256M", // Maximum size of rotated files to keep. compress: false, // Compress rotated files. timestamp: true, // Prefix each entry with timestamp. sessionId: true, // Prefix each entry with session id. opts: {} // Log type-specific options. None in this case. }, stderr: { enabled: true, interval: "1d", maxFiles: 7, maxSize: "256M", compress: false, timestamp: true, sessionId: true, opts: {} }, access: { enabled: true, interval: "1d", maxFiles: 7, maxSize: "256M", compress: false, timestamp: false, sessionId: false, opts: { format: ':date[iso] :remote-addr - :remote-user ":method :url HTTP/:http-version" :status :res[content-length]' } }, license: { enabled: true, interval: "1d", maxFiles: 7, maxSize: "256M", compress: false, timestamp: true, sessionId: true, opts: {} }, ai_chat: { enabled: true, interval: "1d", maxFiles: 7, maxSize: "256M", compress: false, timestamp: false, sessionId: false, opts: {} }, sessions: { enabled: true, interval: "1d", maxFiles: 7, maxSize: "256M", compress: false, timestamp: false, sessionId: false, opts: {} }, atrium_proxy: { enabled: false, // Opt-in; entries already include their own timestamps. interval: "1d", maxFiles: 7, maxSize: "256M", compress: false, timestamp: false, sessionId: false, opts: {} } }

Examples

To adjust the defaults, supply only the log type keys and options that you want to change – everything else keeps its default value.

Example 1: Disable the stdout and stderr Log Files

Useful when an external process manager already captures the process output, so that the same lines are not stored twice:

logging: { stdout: { enabled: false }, stderr: { enabled: false } }

Example 2: Retain Two Weeks of Access Logs

logging: { access: { maxFiles: 14 } }

Example 3: Keep Compressed Session Logs for Longer

Rotate the sessions log daily, keep 30 compressed files, and cap the retained set at 1 GB:

logging: { sessions: { interval: "1d", maxFiles: 30, maxSize: "1G", compress: true } }

For information on how to modify this setting, see Configuration File.