The need for centralized logging
In most cases, log messages are written to files. That is not to say that files are the only, nor the most efficient way of storing logs. However, since most teams are using file-based logs in one form or another, for the time being, I'll assume that is your case as well. If it is, we identified the first thing we should fix. Containers expect us to send logs to stdout
and stderr
. Only log entries forwarded to the standard output are retrievable with docker logs
command. Moreover, tools designed to work with container logs will expect just that. They'll assume that entries are not written to a file but sent to the output. Even without containers, I believe that stdout
and stderr
are where our services should log things. However, that's a story for some other time. For now, we'll concentrate on containers and assume that you are outputting your logs to stdout
and stderr.
If you're not, most logging libraries will allow you to change your logging destination...