Logging in an Async Webapp

So the Python stdlib’s logging library isn’t async (coroutines). So if I log out something I am making blocking calls. The first question is “Does this even matter?”. I know the OS manages file buffering itself, so maybe it’s not blocking for that long. Second question is “If this does matter, how can I utilize the standard lib logger and wrap it in a couroutine?”.

I am aware of the https://github.com/b2wdigital/aiologger package. Having a thread pool managing that sounds overkill though. It does appear that stdout/stderr handlers is implemented as coroutines, and if I am running in a docker container then I’m kind of set with the docker logs functionality, but if I am not running in a container then I would be logging out to a app.log file.

@androiddrew I guess it depends how much you’re logging. I tend to just log errors, so the overhead is minimal. IMO, an async app doesn’t have to be perfectly async to be useful - the main wins are from async network calls. It will be interesting to see if the stdlib logging module will natively support async in the future.