darrin darrin - 1 year ago 199
Node.js Question

Using node.js Bunyan Logging with Intellij

I'm using bunyan logging for a node.js subsystem and typically use intellij IDEA. I would like to use bunyan's pretty printer so that I can get the benefits of buynan/json logs within intellij.

I cannot find any way to do this but feel it must be possible. Has anyone figured out how to do this?


@cyue's answer below works like a champ. When I didn't find something right away I ended up creating something like this in a logging class that I use to wrap this functionality and use it for test servers:

var bunyan = require('bunyan');
var bunyanFormat = require('bunyan-format');
var standardOut = bunyanFormat({outputMode: 'long', levelInString: true});
var errorOut = bunyanFormat({outputMode: 'bunyan', levelInString: true});
var bunyanLogger = bunyan.createLogger({
name: 'tot',
streams: [
stream: process.stdout ,
level: 'trace'
stream: process.stderr ,
level: 'warn'
serializers: {
req: bunyan.stdSerializers.req,
res: bunyan.stdSerializers.res,
err: bunyan.stdSerializers.err,
error: bunyan.stdSerializers.err
eventLogger.on('log', function (log) {
if (resolveLevel(log.level) >= minimumLogLevel) {
bunyanLogger[log.level].apply(bunyanLogger, log.arguments);

The above shouldn't be run in production code but thought it might be useful to some...

Answer Source

I managed for it in WebStorm, write a shell script (mine named node2bunyan) with this:

#!/usr/bin/env bash

node $@ 2>&1 | bunyan --color
exit ${PIPESTATUS[0]}

And add it as a Node interpreter for the Run Configuration: enter image description here

Then you can get: enter image description here

PS. I'm stuck to get the same for PyCharm and reached your question when searching SO, my question for PyCharm

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download