Skip to main content

Configurable Logging in NodeJS

· One min read

We've added the ability to programmatically configure the logger used in the NodeJS SDK. You can now disable logging or add a custom log handler during runtime.

In order to get this feature, you must generate an updated NodeJS SDK from APIMatic.


In order to use logging in NodeJS, you must turn on the Enable Logging flag in the Code Generation settings.

Logger Instance

The NodeJS SDK now creates and maintains its own instance of the Winston logger. Previously, we were using the default static instance provided by Winston for application logging.

Configuring Logger

The logger can be reconfigured with custom transport:

const DailyRotateFile = require("winston-daily-rotate-file");
level: "verbose",
transports: [new DailyRotateFile(opts)]

Logging can also be disabled for the SDK:


The sdk.Logger gets the instance of the Winston logger used by the SDK for all logging actions, assuming that the library (SDK) was imported into the sdk variable.

For more configuration options, checkout the documentation for Winston.