Closed cmcavoy closed 11 years ago
This is analogous to mozilla/CSOL-site#569, I think... Whatever the solution to that ticket ends up being should also apply to this one. Please correct me if I'm wrong though.
Sounds right to me.
Correct...and we should also apply it to Aestimia. 15% more robust.
On Tue, Jun 11, 2013 at 1:37 PM, Brian J Brennan notifications@github.comwrote:
Sounds right to me.
— Reply to this email directly or view it on GitHubhttps://github.com/mozilla/openbadger/issues/217#issuecomment-19283200 .
Okay, here's the strategy:
bunyan
for structured JSON loggingWe inherited the choice to use winston
from the fact that openbadges was originally cloned from the browserid codebase and that's what they were using. It's served us well across several projects so far, but I think it's time to part ways. The transport system is confusing and we only want to output to stdout
/stderr
anyway – saving logs to disk is so 2003.
On that note, bunyan
seems pretty rad – http://blog.nodejs.org/2012/03/28/service-logging-in-json-with-bunyan/. It's fairly simple and designed for spitting out structured logs.
(NOTE: winston
does have a JSON transport, but bunyan
has other benefits which I will touch on below)
Right now our method of getting logs into Graylog2 (a.k.a loggins) is to pump them through syslog and send all of the syslogs to loggins. There are some limitations here:
In light of that, Graylog created the Graylog Extended Log Format, a lightweight JSON based log format designed to be sent over UDP.
While GELF is awesome for getting structured logs into graylog, I don't want to have log-endpoint specific stuff in our apps – it makes them less able to be redeployed if someone wants to use some other log aggregator.
My proposed strategy is to pipe stdout from the app to small utility that converts the structured JSON log stream into a GELF stream and sends it off to loggins. We can use https://github.com/mhart/gelf-stream (which has native support for bunyan
) or https://github.com/robertkowalski/gelf-node (which is dead-simple).
process.once('uncaughtException')
handler to convert stack traces to structured logs before crashing (note: we should definitely still crash because the app will be in an unexpected state).console.log
s. We could also always write another small utility to convert the structured log stream into a human readable stream and pipe through that for dev. We could also only add the uncaughtException
listener when NODE_ENV=production so we get raw stacktraces in development.console.log
s, other non-JSON data and fragmented JSON should not screw it up. This is probably my biggest concern, and I'm willing to revise my strategy if this becomes a problem.
Winston graylog transport