Support logging to stdout/stderr (for cloud deployment)
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.*].pathsettings to point to/dev/stdoutviamailman-extra.cfg -
chown mailman /dev/stdoutbefore runningdocker-entrypoint.shvia a custom container command (supplied in Pod spec)
- Override multiple
- Web:
- For Django: Override the entire
LOGGINGconfig variable viasettings_local.pyto redirect django logs to stdout - For UWSGI: Mount a custom
uwsgi.iniinto/opt/mailman-web, replacing the container-packaged one and omitting all logger definitions (which makes UWSGI send logs to stdout by default)
- For Django: Override the entire
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.
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 👍🏽
This issue has not been updated for more than 1year