Course contentsShow
← Cloud and Infrastructure
Lesson 2048 of 2,98943. Observability - LoggingFree lesson

Container Logging Drivers

Explore Docker and container logging drivers: json-file, syslog, journald, and fluentd.

Container Logging Drivers

What you'll learn: How Docker and container runtimes handle log output through pluggable logging drivers.

When your containerized application writes to stdout or stderr, the container runtime must decide where and how to store those logs. This is where logging drivers come in—they're the configurable backend that captures, formats, and routes your container's log output.

Think of logging drivers like interchangeable mail delivery services: your application "sends" logs the same way (writing to stdout), but the driver determines whether they're stored locally, forwarded to a logging system, or sent to the system journal.

Common Docker Logging Drivers

json-file (default)
Stores logs as JSON objects in local files on the Docker host at /var/lib/docker/containers/<container-id>/<container-id>-json.log. Simple and universal, but can fill disk if not rotated properly. Best for development or when you'll collect logs with an external agent.

syslog
Forwards logs directly to a syslog server (local or remote). Ideal when you already have syslog infrastructure and want centralized logging without intermediate storage.

journald
Sends logs to systemd's journal daemon, integrating container logs with system logs. Query with journalctl. Great for systemd-based Linux hosts where you want unified log management.

fluentd
Streams logs directly to a Fluentd instance. This driver eliminates the need for separate log shippers—your containers push logs straight to your aggregation pipeline. Perfect for cloud-native environments where Fluentd already handles log processing.

You configure the driver per container (docker run --log-driver=syslog) or set a daemon-wide default in /etc/docker/daemon.json. Each driver supports specific options like remote endpoints, tags, or formatting.

Key Takeaway:
Container logging drivers determine where stdout/stderr goes—choose based on your infrastructure (json-file for flexibility, syslog/journald for system integration, fluentd for direct pipeline integration).