docker-mailman icon indicating copy to clipboard operation
docker-mailman copied to clipboard

Support logging to stdout/stderr (for cloud deployment)

Open lorenzo-w opened this issue 2 years ago • 1 comments

When deploying in a cloud context (kubernetes in my case), one usually wants to send all logs to the container's stdout (in a coherent format) and collect them with some log aggregator (e.g. Promtail + Loki). Currently that is only possible for this image with some crude config overrides. My current workaround is:

  • Core:
    • Override multiple [logging.*].path settings to point to /dev/stdout via mailman-extra.cfg
    • chown mailman /dev/stdout before running docker-entrypoint.sh via a custom container command (supplied in Pod spec)
  • Web:
    • For Django: Override the entire LOGGING config variable via settings_local.py to redirect django logs to stdout
    • For UWSGI: Mount a custom uwsgi.ini into /opt/mailman-web, replacing the container-packaged one and omitting all logger definitions (which makes UWSGI send logs to stdout by default)

One or more dedicated environment variables to make the entire mailman suite switch to this logging behavior would be quite helpful and feel less hacky. I'd be willing to make a PR.

lorenzo-w avatar Apr 18 '23 13:04 lorenzo-w

Thanks for opening this, i've been thinking about this for a while too.

The steps you have makes sense to me. Here are a few suggestoins:

Override multiple [logging.*].path settings to point to /dev/stdout via mailman-extra.cfg

You can do this by propagating all the sub-loggers to main by specifying propagate: yes under each [logging.*] loggers and only updating path for the root logger.

We can use something like MAILMAN_LOG_TO_STDOUT as a way to configure the containers for the same.

I'd be happy to accept a PR if you open one for the same 👍🏽

maxking avatar Jun 19 '23 03:06 maxking

This issue has not been updated for more than 1year

github-actions[bot] avatar Jun 18 '24 22:06 github-actions[bot]