The simplest json logger. Include typescript definitions.

Downloads in past


464.0.02 years ago3 years agoMinified + gzip package size for @vizir/simple-json-logger in KB


A fast, simple and opinionated json logger to stdout.
npm version Node.js CI


This library is designed to be an easy and fast way to log json messages to stdout.
If you want a more advanced solution, we recommend to you use winston.


$ npm install @vizir/simple-json-logger


NodeJS Sample with Javascript

const { Logger } = require("@vizir/simple-json-logger");

const logger = new Logger({
  app: "ConsoleApplication",
  requestId: "3a7d3223-e96f-47da-b3bb-73f609b9f55d",
logger.debug("debug message", { extraInfo: 123 });
logger.info("info message", { extraInfo: "abc" });
logger.warn("warn message", { moreInfo: "abc123" });
logger.error("error message", { otherInfo: "qwerty" });

Security Filtering

By default, the logger will filter some sensitive values from logs output. They will verify if an object key, contain some of the following words: (The validation is case insensitive)
  • Authorization
  • Password
  • Secret
  • Token
  • Key

You can add or remove the default blacklist, using the includeBlackList or excludeBlackList attribute into options, as following:
const logger = new Logger(
    app: "ConsoleApplication",
    requestId: "3a7d3223-e96f-47da-b3bb-73f609b9f55d",
    includeBlackList: ["myPasswordField"],
    excludeBlackList: ["accessToken"],
logger.error("error message", { myPasswordField: "qwerty" });

The output of the following command are:
  "app": "ConsoleApplication",
  "requestId": "3a7d3223-e96f-47da-b3bb-73f609b9f55d",
  "level": "error",
  "datetime": "2020-05-20T00:20:10.432Z",
  "message": "origin: error message",
  "myPasswordField": "*sensitive*"


Tested in Node.js 10-12.


The MIT License (MIT)