

Instead, logspout collects logs from other containers that use the json-file or journald logging drivers and routes them according to the configuration options set on the Docker command line. Logspout is essentially a log routing appliance that directs log messages from your containers to a syslog server, but doesn’t provide any other features like searching through log history or log management-that’s the job of log management tools. It’s possible to build more complex log management setups with logspout, a log router for Docker containers. But if you need total control over where your logs are sent, you need a way to route your logs-and logspout is just the tool for the job.
#Docker syslog format driver
For all other drivers, you need to inspect the logs on the destination side.įor most users, the json-file logging driver or one of the other built-in drivers work well enough.

That command only works with the json-file and journald drivers. However, there’s one major caveat with most of the logging drivers that ship with Docker: you cannot use the docker logs command to inspect the logs. Logging drivers can be configured per-node at the daemon level by using the log-driver option in the daemon.json file, or on a per-container basis with the –log-driver flag. For example, if you’re collecting logs in Amazon CloudWatch Logs, you can use the awslogs logging driver to write log messages from your container directly to your Amazon CloudWatch Logs account. The default driver is json-file, which formats all messages as JSON and writes them to a per-container text file.Īdditionally, Docker has a number of logging drivers available. Logging drivers provide a mechanism to record text strings. In Docker, everything written to stdout and stderr is implicitly sent to a logging driver. For the syslog daemon-the de facto system logger for many scenarios-doing so involved using the syslog() system call from your application. With other systems, recording application log messages was done explicitly by writing those messages to the system logger. If you’re managing large numbers of containers with Docker’s swarm mode, the importance of aggregating logs into a central docker logs location cannot be overstated-it’s the ultimate way to use the power of logging in Docker at scale. Getting logging in Docker right involves choosing the right option for collecting logs and analyzing them holistically. Being able to gather useful information from your Docker container logs can mean the difference between a minor issue and a critical outage.īut there are numerous ways to record logs in Docker, most of which don’t exist for traditional application logging. When things inevitably start going wrong you need diagnostic information to figure out how and why.

Unfortunately, as every sysadmin and developer knows, that is never the case. Life would be much simpler if applications running inside containers always behaved correctly.
