JsonLogger
Ce contenu n’est pas encore disponible dans votre langue.
Defined in: src/Logger.ts:163
Structured-logging logger that emits one \n-delimited JSON object
per record to process.stdout (or an injected JsonLogSink).
Each record always carries the four core fields — ts, level,
source, and msg — followed by the merged static + dynamic MDC
(static from withFields, dynamic from LogContext.run, with
dynamic winning on key collision to match the “innermost scope wins”
intuition). Extra positional ...args from
log.info(msg, extra1, extra2) go under an args array; the common
shape log.info('processed', { items: 42 }) simply puts {items:42}
into args[0] so log aggregators can index nested keys.
Wire it in at system construction:
const system = ActorSystem.create('my-app', { logger: new JsonLogger() });Output (one line, line-wrapped here for readability):
{"ts":"2026-05-14T12:34:56.789Z","level":"info", "source":"actor-ts://my-app/user/order", "msg":"placing order", "correlationId":"abc-123","userId":"user-42", "args":[{"items":42}]}No pretty-printing, no colour codes, no level-prefix shorthand —
machine-readable by design. For human-readable text logs use the
default ConsoleLogger; for OTel-pipeline ingestion bridge a
JsonLogger-equivalent via otelLogger({ api }).
Error rendering. Pass an Error and the logger serialises
name, message, and stack (the bare object would otherwise
become "{}" because Error’s own enumerable surface is empty).
JSON-safety. Values are sent through JSON.stringify with a
replacer that handles BigInt, circular references, and
undefined/function values gracefully — a log call never throws.
Implements
Section titled “Implements”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new JsonLogger(
level?,source?,staticFields?,sink?):JsonLogger
Defined in: src/Logger.ts:164
Parameters
Section titled “Parameters”level?
Section titled “level?”LogLevel = LogLevel.Info
source?
Section titled “source?”string = ''
staticFields?
Section titled “staticFields?”LogContextData = {}
JsonLogSink = stdoutSink
Returns
Section titled “Returns”JsonLogger
Properties
Section titled “Properties”level:
LogLevel=LogLevel.Info
Defined in: src/Logger.ts:165
Implementation of
Section titled “Implementation of”Methods
Section titled “Methods”debug()
Section titled “debug()”debug(
msg, …args):void
Defined in: src/Logger.ts:201
Parameters
Section titled “Parameters”string
…unknown[]
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”error()
Section titled “error()”error(
msg, …args):void
Defined in: src/Logger.ts:204
Parameters
Section titled “Parameters”string
…unknown[]
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”info()
Section titled “info()”info(
msg, …args):void
Defined in: src/Logger.ts:202
Parameters
Section titled “Parameters”string
…unknown[]
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”warn()
Section titled “warn()”warn(
msg, …args):void
Defined in: src/Logger.ts:203
Parameters
Section titled “Parameters”string
…unknown[]
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”withFields()
Section titled “withFields()”withFields(
fields):Logger
Defined in: src/Logger.ts:210
Create a logger with extra static fields baked in. Unlike
LogContext (which is dynamic / per-async-stack), withFields
stamps the same fields on every record this logger emits — handy
for component-level tagging like { component: 'shard-coordinator' }
or { shardId: 12 } on a per-entity logger.
Parameters
Section titled “Parameters”fields
Section titled “fields”Returns
Section titled “Returns”Implementation of
Section titled “Implementation of”withSource()
Section titled “withSource()”withSource(
source):Logger
Defined in: src/Logger.ts:206
Create a logger bound to a source (e.g. an actor path).
Parameters
Section titled “Parameters”source
Section titled “source”string