log4js-elasticsearch
log4js-elasticsearch copied to clipboard
Cleanup handlers
exit can't be used to flush the logs, as you can't run async stuff there
https://nodejs.org/docs/v4.2.4/api/process.html#process_event_exit
beforeExit can run async stuff, but might yield false positives (if stuff causes the event loop to fire up again) and won't necessarily be called on hard shutdowns (process.exit() or uncaught exceptions)
@issacg thanks for looking into this. The code in place is only a best effort at flushing the logs. It is correct that some logs will get lost on a hard shutdown.