Skip to content

Question: How can I ensure all asynchronous logged events are actually sent before closing process? #196

Answered by reidmorrison
jasonwbarnett asked this question in Q&A
Discussion options

You must be logged in to vote

Semantic Logger has a built-in flush that occurs before a process exits: https://github.com/reidmorrison/semantic_logger/blob/master/lib/semantic_logger.rb#L44

We use sigterm heavily in our AWS ECS deployment for when docker containers are being scaled down.

We had issues previously when other at_exit handlers were not finishing quickly enough after a sigterm, which caused AWS ECS to hard kill the process causing messages to be lost. Once the other at_exit handlers were fixed, we get all our log messages now.

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by reidmorrison
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
2 participants
Converted from issue

This discussion was converted from issue #175 on January 17, 2022 20:50.