Twelve-Factor Logging
I’ve been developing node.js web servers for quite a while now yet still there’s one thing that confuses me. Why on earth are all the logging frameworks so complicated?
Consider winston. Great logging library. But so big and complex. All those transports, all those settings.
Twelve-Factor Manifesto states that app shouldn’t concern itself with where it’s logs are stored. I’ve always thought this is spot on. Don’t mix concerns, log to stdout
and let a dedicated log handler piece deal with the details of where the logs actually go. And let another piece deal with log searching.
On most of my projects, I use winston but I only ever use the (default) console
transport and default logger. Then outside the application there’s a remote_syslog2 process running as a daemon routing all my logs to Papertrail. Which is also where the logs get filtered and queried.
That way, when I want to log something in my app, I can focus more on the whats and less on the hows.
How do you log? I'd be thrilled to know! I’m @tomasbrambora.