Is there a length limit for Node.js console.log?

Is there a limit on console.log output length in Node.js? The following numbers print to 56462 and then stop. This was due to the fact that we were returning data from MySQL, and the output simply stopped after 327k characters.

var out = ""; 
for (i = 0; i < 100000; i++) {
    out += " " + i; 
}

console.log(out); 

The line itself seems beautiful, as it returns the last few numbers to 99999:

console.log(out.substring(out.length - 23)); 

Returns:

99996 99997 99998 99999

Used by Node v0.6.14.

+4
source share
2 answers

node > 6.0

const output = fs.createWriteStream('./stdout.log');
const errorOutput = fs.createWriteStream('./stderr.log');
// custom simple logger
const logger = new Console(output, errorOutput);
// use it like console
var count = 5;
logger.log('count: %d', count);
// in stdout.log: count 5
-1

All Articles