is it possible to use multiple logging drivers for the same container - say fluentd and json?
Thank you.
is it possible to use multiple logging drivers for the same container - say fluentd and json?
Thank you.
As of 18.03, Docker Engine Enterprise(EE) supports multiple log drivers, but it is not in the Community Edition(CE):
https://docs.docker.com/ee/engine/release-notes/#18031-ee-1-2018-06-27
Dual logging is available in docker CE since version 20.10.1.
The feature was previously only available in Docker Enterprise since version 18.03.1-ee-1.
The official documentation chapter "Dual Logging" doesn't reflect this (as of 2021-01-04 ).
The feature has been open-sourced in pull request #40543 and was merged into master on 2020-02-27.
The related GitHub issue #17910 in moby/moby was closed with the following comment:
The upcoming Docker 20.10 release will come with the feature described above ("dual logging"), which uses the local logging driver as a ring-buffer, which makes docker logs work when using a logging driver that does not have "read" support (for example, logging drivers that send logs to a remote logging aggregator).
No you can specify a single logging driver as stated in the official documentation :
You cannot specify more than one log driver.
The log-driver documentation indicates that too :
To configure the Docker daemon to default to a specific logging driver, set the value of log-driver to the name of the logging driver in the daemon.json file...`
{
"log-driver": "syslog"
}
You can see that "log-driver" expects a string and not an array.
In fact, since Docker Engine Enterprise 18.03.1-ee-1, Docker has "just" enable a dual logging feature that allows to configure any logging driver log while being still the possibility to read them with docker logs.
For example before that feature, specifying that driver in the daemon.json :
{
"log-driver": "syslog"
}
allowed to redirect the logs to a syslog server but that also made Docker to not publish any longer logs to the local logging driver.
Now that is not the case, the information is available in both destination.
Starting with Docker Engine Enterprise 18.03.1-ee-1, you can use docker logs to read container logs regardless of the configured logging driver or plugin. This capability, sometimes referred to as dual logging, allows you to use docker logs to read container logs locally in a consistent format, regardless of the remote log driver used, because the engine is configured to log information to the “local” logging driver.