Well, I use console.log() for logging. Simple as that. That method writes a string to stdout and you can see it in a console. Since it is just a console, you can even color and style the font for better readability.
While my application is running, I additionally write rapidly repeating events (e.g. someone calls my API or makes a web request) to a file. I really recommend some kind of streaming log-rotation mechanism for that.
Since errors and warnings are very important I recommend logging them to a separate place. I like databases, but you might just use another file or even console.warn() or console.error() which write to stderr (which is equal to stdout by default), as well.
Marco Alka
Software Engineer, Technical Consultant & Mentor
Well, I use
console.log()for logging. Simple as that. That method writes a string to stdout and you can see it in a console. Since it is just a console, you can even color and style the font for better readability.While my application is running, I additionally write rapidly repeating events (e.g. someone calls my API or makes a web request) to a file. I really recommend some kind of streaming log-rotation mechanism for that.
Since errors and warnings are very important I recommend logging them to a separate place. I like databases, but you might just use another file or even
console.warn()orconsole.error()which write to stderr (which is equal to stdout by default), as well.