nodejs - pipe appjs console to a file

I try to pipe appjs console to a file with this code:

var fs = require('fs');
var logStream = fs.createWriteStream(__dirname+ '/log.txt', { flags: 'a' });
process.stdout.pipe(logStream);
process.stderr.pipe(logStream);
console.log("test");

It creates an empty file, but nothing more... With node.exe the "test" goes into the console, not into the log file. The platform is win32, but I don't think it counts.

What's the problem with the code?

you have to define getters for process.stdin, process.stdout and process.stderr

var fs = require("fs")
  , errlog = fs.createWriteStream("./err.log", { flags: 'a' })

process.__defineGetter__("stderr", function(){
  return errlog 
})

process.stderr.write("test")

this should work