Logging

Logging

Scout logs its own internal activity — agent connection, request lifecycle, errors — separately from your application’s logs. (To send your app’s logs to Scout instead, see Log Management.)

Nothing is logged until you set a level — there’s no default:

export SCOUT_LOG_LEVEL=debug

Once set, Scout logs to the console automatically, no logFn needed:

[2026-07-21T18:03:11.402Z] [DEBUG] [pid:41822] [scout] active configuration:
[2026-07-21T18:03:11.403Z] [DEBUG] [pid:41822] [scout]   name: "my-app"
[2026-07-21T18:03:11.403Z] [DEBUG] [pid:41822] [scout]   key: "abcd***"

At debug, the first thing logged is a full dump of Scout’s active configuration (key/logsIngestKey masked) — check it first if something’s misconfigured, since it reflects what Scout actually resolved from env vars, code, and defaults. The [pid:N] prefix helps when multiple Scout-instrumented processes share one log stream (PM2, cluster mode).

Custom Logging Destinations

To route Scout’s logs elsewhere — your own logger, a file, an aggregator — pass a logFn with the signature (msg: string, level: LogLevel) => void:

const { init, consoleLogFn } = require("@scout_apm/scout-apm");

init({
  name: "<application name>",
  key: "<scout key>",
  monitor: true,
  logFn: consoleLogFn, // the built-in console formatter, if you want it explicitly
});

If you’re using winston, build a logFn by passing a winston.Logger to buildWinstonLogFn:

const { init, buildWinstonLogFn } = require("@scout_apm/scout-apm");

init({
  name: "<application name>",
  key: "<scout key>",
  monitor: true,
  logFn: buildWinstonLogFn(yourLogger),
});

If a winston.Logger instance is provided, Scout’s logging defaults to the same log level as the instance, otherwise it defaults to ERROR. You may set the logging to a stricter level to quiet the agent’s logging via the logLevel in the config sub-object (or SCOUT_LOG_LEVEL via ENV). The underlying LoggerInterface’s level will take precedence if it is tighter than the logLevel configuration.

Agent connection failures and other startup errors always log at error, regardless of level, so they show up even with a strict SCOUT_LOG_LEVEL.

Log Levels

The possible log levels are as follows: