Skip to content

Instantly share code, notes, and snippets.

@ryanhamley
Created November 5, 2015 18:37
Show Gist options
  • Save ryanhamley/d159efd41b0c67b0067d to your computer and use it in GitHub Desktop.
Save ryanhamley/d159efd41b0c67b0067d to your computer and use it in GitHub Desktop.
Log to a file with Node
var log_file = fs.createWriteStream(__dirname + '/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');
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment