How to configure logging output in json format?

  • Hello Guys,

    Please help us understand how to configure log output in json format or how to integrate JSreport logs with Kibana?

  • jsreport uses the winston logging package so pretty much everything you find out in the winston docs can be applied in the jsreport.

    To enable json for all transports, add a default logging config to jsreport.config.json.

     "logger": {
        "console": {
          "transport": "console",
          "level": "debug"
        "file": {
          "transport": "file",
          "level": "debug",
          "filename": "logs/log.txt"
        "error": {
          "transport": "file",
          "level": "error",
          "filename": "logs/error.txt"

    And the update the app server.js file with the following. It will instruct all transports to format in json.

    const jsreport = require('jsreport')()
    if (process.env.JSREPORT_CLI) {
      // export jsreport instance to make it possible to use jsreport-cli
      module.exports = jsreport
    } else {
      jsreport.afterConfigLoaded(() => {
        const winston = require('winston')
        jsreport.logger.format = require('winston').format.combine(
      jsreport.init().then(() => {
        // running
      }).catch((e) => {
        // error during startup

Log in to reply

Looks like your connection to jsreport forum was lost, please wait while we try to reconnect.