JsonLogger
Este conteúdo não está disponível em sua língua ainda.
Defined in: src/Logger.ts:192
Structured-logging logger that emits one \n-delimited JSON object
per record to process.stdout (or an injected JsonLogSink).
Each record always carries ts, level, and msg; source is
emitted only when one is bound (via withSource). These are
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', ActorSystemOptions.create().withLogger(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:193
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:194
Implementation of
Section titled “Implementation of”Methods
Section titled “Methods”debug()
Section titled “debug()”debug(
message, …args):void
Defined in: src/Logger.ts:230
Parameters
Section titled “Parameters”message
Section titled “message”string
…unknown[]
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”error()
Section titled “error()”error(
message, …args):void
Defined in: src/Logger.ts:233
Parameters
Section titled “Parameters”message
Section titled “message”string
…unknown[]
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”info()
Section titled “info()”info(
message, …args):void
Defined in: src/Logger.ts:231
Parameters
Section titled “Parameters”message
Section titled “message”string
…unknown[]
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”warn()
Section titled “warn()”warn(
message, …args):void
Defined in: src/Logger.ts:232
Parameters
Section titled “Parameters”message
Section titled “message”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:239
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:235
Create a logger bound to a source (e.g. an actor path).
Parameters
Section titled “Parameters”source
Section titled “source”string
