Node.js console.log() in txt file

后端 未结 6 505
耶瑟儿~
耶瑟儿~ 2020-12-24 03:29

I have another question (last question). At the moment i am working on a Node.js project and in this I have many console.log() functions. This has worked ok

6条回答
  •  春和景丽
    2020-12-24 04:02

    const fs = require('fs');
    const myConsole = new console.Console(fs.createWriteStream('./output.txt'));
    myConsole.log('hello world');
    

    This will create an output file with all the output which can been triggered through console.log('hello world') inside the console.

    This is the easiest way to convert the console.log() output into a text file.`

提交回复
热议问题