Looking at some videos about promises in Node.js, the guy uses console.error()
to print things he know would error out and console.log()
for everything else. Is there a main difference between these two functions besides printing things in distinct colours?
console.error()
writes to stderr
, whereas console.log()
writes to stdout
as described in the doc.
In a default run of nodejs, both stdout
and stderr
go to the console, but obviously, they could be directed different places and could be used differently. For example, when using tools such as forever, the two streams are logged to separate log files so they can be examined separately.
The presumption is that console.error()
may contain more serious information that might want to be looked at separately, but that is really up to how you use console.log()
vs. console.error()
in your own program.