Jump to content

node.js console.log output to file


gleason

Recommended Posts

Has anyone had any success logging node.js console.log to a file?

 

Was reading some other post about having to use home/username/logfile but coming up short

 

I did try home/mule/debug.log as well just for information

 

const fs = require('fs');

var util = require('util');


var log_file = fs.createWriteStream(__dirname + 'home/mule/node/debug.log', {flags : 'w'});
var log_stdout = process.stdout;

console.log = function(d) { //
  log_file.write(util.format(d) + '\n');
  log_stdout.write(util.format(d) + '\n');
};

 

attempting to use this information to troubleshoot my code.

 

potentially better idea to modify start.py to log errors but no clue how to go about doing that.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...