Node.JS Winston 日志记录,Visual Studio 调试控制台未输出

3
在 Visual Studio Code 终端上以 "node app" 运行时,进行 winston 日志记录会输出控制台日志。但是,Visual Studio 的调试控制台选项卡不会打印控制台日志。为什么? 图片描述 图片描述

1
console.log 只会在 controller.js 中打印,不会在服务器端打印。 - Vinoth
这是因为在内部级别上,console.logprocess.stdout的包装器IO操作,所以它不会显示出来。但是winston是一个简单的程序,您需要特别配置才能将其写入输出。 - Alexandru Olaru
1个回答

6
以下是我的launch.json文件,关键字是"outputCapture": "std",
{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "type": "node",
            "request": "launch",
            "name": "Launch Program",
            "outputCapture": "std", //key is this line
            "program": "${workspaceFolder}/bin/www"
        }
    ]
}

有关在调试模式下运行测试的建议吗? - Custodio

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接