Production Logging Drivers (json-file, local, syslog, fluentd, awslogs)
Pick logging drivers that fit your aggregation stack and retention needs.
In plain words
Select the driver with the observability team and verify loss/backpressure behavior during collector failure.
Think of it like…
A logging driver is the post office contract: local pickup remains available, express courier needs its depot, and each courier charges/limits different parcel sizes.
Where you’ve seen it
In practice, logging: { driver: local, options: { max-size: 20m, max-file: 4, compress: "true" } } is the concrete move for this job: pick logging drivers that fit your aggregation stack and retention needs. The release is not accepted until generate logs above the rotation boundary and test docker inspect driver plus docker logs availability while the collector is deliberately offline confirms the result.
Words you’ll hear
- json-file
- The implementation control in
logging: { driver: local, options: { max-size: 20m, max-file: 4, compress: "true" } }for pick logging drivers that fit your aggregation stack and retention needs. - fluentd
- The result to observe with
generate logs above the rotation boundary and test docker inspect driver plus docker logs availability while the collector is deliberately offline, rather than infer from a successful command alone. - awslogs
- The production boundary exposed when assuming every driver supports max-size/max-file, or configuring a remote driver with no data-loss monitor.
Visual diagram
Theory & deep dive
json-file control path
The concrete mechanism is logging: { driver: local, options: { max-size: 20m, max-file: 4, compress: "true" } }. The observable result is generate logs above the rotation boundary and test docker inspect driver plus docker logs availability while the collector is deliberately offline; if those disagree, inspect the runtime evidence before changing unrelated settings.
Pick logging drivers that fit your aggregation stack and retention needs. Keep json-file, fluentd and awslogs in the same deployment record so the intent and the observed state cannot drift apart.
logging: { driver: local, options: { max-size: 20m, max-file: 4, compress: "true" } }
generate logs above the rotation boundary and test docker inspect driver plus docker logs availability while the collector is deliberately offline, not with command success alone.awslogs failure boundary
A driver that blocks on a remote endpoint can affect the application; a driver with max-buffer-size may drop instead. awslogs credentials and retention/region errors can be visible only after a container starts successfully. The narrow failure to design for is assuming every driver supports max-size/max-file, or configuring a remote driver with no data-loss monitor.
Accept this compromise explicitly: local gives simple bounded access; fluentd/Loki/Cloud drivers centralize retention but add transport and collector failure modes. The controlled check-generate logs above the rotation boundary and test docker inspect driver plus docker logs availability while the collector is deliberately offline-also identifies the point where a different design is safer.
Exercise this failure safely: assuming every driver supports max-size/max-file, or configuring a remote driver with no data-loss monitor.
How it works, step by step
Step 1 of 41. State the boundary
Write down why the workload needs this: A driver that blocks on a remote endpoint can affect the application; a driver with max-buffer-size may drop instead. awslogs credentials and retention/region errors can be visible only after a container starts successfully.
- Intent
- json-file
When to use it & trade-offs
What it is
json-file keeps per-container uncompressed JSON logs, local adds rotation/compression characteristics, syslog forwards to a daemon, fluentd sends structured messages to a collector and awslogs writes to CloudWatch. Driver selection changes docker logs, delivery and disk/backpressure behavior.
Why it matters: A driver that blocks on a remote endpoint can affect the application; a driver with max-buffer-size may drop instead. awslogs credentials and retention/region errors can be visible only after a container starts successfully.
When to reach for it
- The fit is strongest for this job: pick logging drivers that fit your aggregation stack and retention needs. Pair it with
generate logs above the rotation boundary and test docker inspect driver plus docker logs availability while the collector is deliberately offlinein the runbook. - Production json-file changes should make fluentd observable through
logging: { driver: local, options: { max-size: 20m, max-file: 4, compress: "true" } }, rather than trusting the runtime default. - Keep a rollback example for the case where assuming every driver supports max-size/max-file, or configuring a remote driver with no data-loss monitor.
When to avoid or be careful
- Do not accept command success while the system can still fail by assuming every driver supports max-size/max-file, or configuring a remote driver with no data-loss monitor.
- Avoid erasing awslogs protection merely to dodge this cost: “local gives simple bounded access; fluentd/Loki/Cloud drivers centralize retention but add transport and collector failure modes”.
- Do not replace the evidence path-
generate logs above the rotation boundary and test docker inspect driver plus docker logs availability while the collector is deliberately offline-with a screenshot or a mutable tag.
logging: { driver: local, options: { max-size: 20m, max-file: 4, compress: "true" } }: practical choices
Strengths: json-file keeps per-container uncompressed JSON logs, local adds rotation/compression characteristics, syslog forwards to a daemon, fluentd sends structured messages to a collector and awslogs writes to CloudWatch. Driver selection changes docker logs, delivery and disk/backpressure behavior.
Watch out: local gives simple bounded access; fluentd/Loki/Cloud drivers centralize retention but add transport and collector failure modes.
Strengths: It can begin with logging: { driver: local, options: { max-size: 20m, max-file: 4, compress: "true" } } and fewer surrounding controls.
Watch out: It silently accepts assuming every driver supports max-size/max-file, or configuring a remote driver with no data-loss monitor, which makes the result hard to reproduce after promotion.
Strengths: A driver that blocks on a remote endpoint can affect the application; a driver with max-buffer-size may drop instead. awslogs credentials and retention/region errors can be visible only after a container starts successfully.
Watch out: The platform adds an ownership and debugging layer; retain generate logs above the rotation boundary and test docker inspect driver plus docker logs availability while the collector is deliberately offline as the direct check.
Interview signals & numbers to know
When this topic comes up
- logging: { driver: local, options: { max-size: 20m, max-file: 4, compress: "true" } }
- generate logs above the rotation boundary and test docker inspect driver plus docker logs availability while the collector is deliberately offline
- Failure signature: assuming every driver supports max-size/max-file, or configuring a remote driver with no data-loss monitor
- Trade-off: local gives simple bounded access; fluentd/Loki/Cloud drivers centralize retention but add transport and collector failure modes.
Benchmarks & rules of thumb
- 20 MB
- per file local example
- 4 files
- local rotation count
- json and local
- drivers commonly compatible with docker logs
Common mistakes & follow-ups
Common interview mistakes
- Treating a successful
logging: { driver: local, options: { max-size: 20m, max-file: 4, compress: "true" } }as proof and skippinggenerate logs above the rotation boundary and test docker inspect driver plus docker logs availability while the collector is deliberately offline. - Assuming every driver supports max-size/max-file, or configuring a remote driver with no data-loss monitor
- Optimizing json-file without accepting that local gives simple bounded access; fluentd/Loki/Cloud drivers centralize retention but add transport and collector failure modes.
Likely interviewer follow-ups
- Why does
logging: { driver: local, options: { max-size: 20m, max-file: 4, compress: "true" } }address json-file here rather than through application code? - How would you distinguish healthy fluentd from the failure “assuming every driver supports max-size/max-file, or configuring a remote driver with no data-loss monitor” using
generate logs above the rotation boundary and test docker inspect driver plus docker logs availability while the collector is deliberately offline? - When would this trade-off-“local gives simple bounded access; fluentd/Loki/Cloud drivers centralize retention but add transport and collector failure modes”-justify a different awslogs design?
logging: { driver: local, options: { max-size: 20m, max-file: 4, compress: "true" } }-and one proof-generate logs above the rotation boundary and test docker inspect driver plus docker logs availability while the collector is deliberately offline. Then name the boundary: assuming every driver supports max-size/max-file, or configuring a remote driver with no data-loss monitor.Knowledge check
Put it into practice
Practice related interview Q&A
Apply Production Logging Drivers (json-file, local, syslog, fluentd, awslogs) with generative AI interview Q&A and hands-on practice.