gpt4 book ai didi

node.js - 如何在 NodeJS (Linux) 中将日志写入文件?

转载 作者:太空宇宙 更新时间:2023-11-04 11:45:47 24 4
gpt4 key购买 nike

<分区>

我的简单脚本 (test.js):

const x = 10;
console.log('Number X = ' + x);
throw new Error('emulating some error in the code');
console.log('Finish');

例如,我用命令启动我的脚本:node test.js >> log.txt

我只能在控制台中看到错误消息。错误没有写在log.txt中

如何在 log.txt 中写入错误消息?

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com