LoggingBehavior
Defined in: packages/pipeline/src/behaviors/logging.behavior.ts:178
Pipeline behavior that logs each request/response and execution timing.
Emits the incoming request, a completion metric (duration), and the response,
each at a configurable log level (see LoggingBehaviorOptions). Request and
response payloads are excluded by default and can be opted in, with key-based
exclusion/redaction. Logging and serialization failures do not change the
handler result or error. If the wrapped handler throws,
the error is logged — including its stack trace and, when present, the error’s
optionalParams (see ErrorWithOptionalParams) — and then re-thrown
unchanged. Writes through the logger passed to the constructor, or console.
Example
Section titled “Example”const pipeline = createPipeline({ behaviors: [new LoggingBehavior(pinoAdapter)] });Implements
Section titled “Implements”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new LoggingBehavior(
logger?):LoggingBehavior
Defined in: packages/pipeline/src/behaviors/logging.behavior.ts:181
Parameters
Section titled “Parameters”logger?
Section titled “logger?”Returns
Section titled “Returns”LoggingBehavior
Methods
Section titled “Methods”handle()
Section titled “handle()”handle(
context,next):Promise<unknown>
Defined in: packages/pipeline/src/behaviors/logging.behavior.ts:196
Logs the request, a duration metric, and the response or error around
next(), using the options from context.getBehaviorOptions(LoggingBehavior)
and the defaults documented on LoggingBehaviorOptions.
Parameters
Section titled “Parameters”context
Section titled “context”The pipeline context for the current request.
Delegate that invokes the next behavior/handler in the chain.
Returns
Section titled “Returns”Promise<unknown>
The value resolved by next().
Throws
Section titled “Throws”Whatever next() throws, unchanged, after logging it. A logging
or serialization failure never changes the returned value or the error.