jsreport uses the winston logging package so pretty much everything you find out in the winston docs can be applied in the jsreport.
https://jsreport.net/learn/configuration#logging
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.logger.format,
winston.format.json()
)
})
jsreport.init().then(() => {
// running
}).catch((e) => {
// error during startup
console.error(e.stack)
process.exit(1)
})
}