log4js-elasticsearch icon indicating copy to clipboard operation
log4js-elasticsearch copied to clipboard

Cleanup handlers

Open issacg opened this issue 9 years ago • 1 comments

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 avatar Jan 12 '16 10:01 issacg

@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.

hmalphettes avatar Jan 13 '16 02:01 hmalphettes