Node-bunyan: Bunyan does not print to Stdout when debugging in VSCode

Created on 30 Oct 2017  路  6Comments  路  Source: trentm/node-bunyan

When I debug my application with Visual Studio Code, bunyan does not print anything in the debugging console.

Logging on files works fine.

Steps to reproduce:
Create a project in VSCode and lunch it in debug within VSCode (F5)

'use strict'

var logger = require('bunyan').createLogger({
  name: 'mylogger',
  level: 'debug'
})

console.log('before bunyan logs')

logger.debug('debug')
logger.info('info')
logger.warn('warn')
logger.error('error')

console.log('after bunyan logs')

Most helpful comment

Add the following to your launch configuration..

"outputCapture": "std",

All 6 comments

What version of node?

Yeah sorry, I didn't put it. So, I have tested with Node v8.8.1.
Non-debug mode works as expected, printing:

{"name":"mylogger","hostname":"WK-025","pid":7020,"level":20,"msg":"debug","time":"2018-02-13T07:50:01.222Z","v":0}
{"name":"mylogger","hostname":"WK-025","pid":7020,"level":30,"msg":"info","time":"2018-02-13T07:50:01.226Z","v":0}
{"name":"mylogger","hostname":"WK-025","pid":7020,"level":40,"msg":"warn","time":"2018-02-13T07:50:01.227Z","v":0}
{"name":"mylogger","hostname":"WK-025","pid":7020,"level":50,"msg":"error","time":"2018-02-13T07:50:01.228Z","v":0}

Add the following to your launch configuration..

"outputCapture": "std",

Perfect, that solved the problem. Thank you.

@sppatel dosen't work for me, buyan dosen't have this property
image

I resolve that the property is in the config of vscode (launch.json):

image

Example:
{ "version": "0.2.0", "configurations": [ { "name": "Debug ts-node", "type": "node", "request": "launch", "program": "${workspaceRoot}/node_modules/ts-node/dist/bin.js", "outputCapture": "std", "args": [ "${workspaceRoot}/server/server.ts" ], "cwd": "${workspaceRoot}", "protocol": "inspector" } ] }

Was this page helpful?
0 / 5 - 0 ratings

Related issues

yelworc picture yelworc  路  5Comments

marnusw picture marnusw  路  11Comments

raybooysen picture raybooysen  路  3Comments

shaucorp picture shaucorp  路  5Comments

simonexmachina picture simonexmachina  路  8Comments