Integrating third-party logging applications such as Pino or Bunyan
If our application already utilizes a third-party application for logging, Sequelize can offer support for integrating with such systems. This section references two logging applications, Pino and Bunyan, but any logging library or framework should also be compatible with Sequelize.
Integrating with Pino
Pino is a low overhead Node.js logger that also offers redaction, transport, and asynchronous support. Presuming our project has Pino installed within our node_modules
folder, we can simply integrate it with our Sequelize instance as follows:
const logger = require('pino')(); const sequelize = new Sequelize('sqlite::memory:', { logging: (msg) => logger.debug(msg) });
Now, when we call sequelize.log
manually or execute queries, the logs will be sent to the Pino logging library. The output would look similar to this:
{"level":30,"time"...