✦ For everyone, free.

Practical knowledge for real and everyday life

Home

9.4.3.4 Logs Timestamp Display

A focused guide to Logs Timestamp Display, connecting core concepts with practical Docker and container operations.

Logs timestamp display, through the -t flag on docker compose logs, adds the exact time each log line was produced, useful for correlating log entries with when specific events actually occurred, especially when reviewing a span of historical output.

Adding Timestamps to Log Output

The -t flag prefixes each log line with its associated timestamp.

docker compose logs -t api
api_1  | 2026-06-24T10:15:03.421Z Server listening on port 8080
api_1  | 2026-06-24T10:15:05.892Z Handling request: GET /health

Each line now clearly shows precisely when it was produced, information not visible by default without this flag.

Why Timestamps Matter for Correlating Events

Determining how much time elapsed between two log entries, or correlating a log entry with an external event (a deployment, a reported user issue) known to have occurred at a specific time, requires this timestamp information to be visible.

docker compose logs -t api | grep "10:1[5-6]"

Filtering for a specific time window, made possible by having timestamps visible, helps narrow log review to exactly the period relevant to whatever's being investigated.

Combining Timestamps With Other Log Options

Timestamp display works alongside other logs options, such as tail filtering or follow mode, without conflicting with them.

docker compose logs -t -f --tail=20 api
Why Timestamps Aren't Always Necessary

For quickly checking a service's most recent activity without needing to correlate it against anything external, the relative ordering of log lines alone is often sufficient, making timestamp display an optional addition rather than something needed for every log review.

docker compose logs --tail=10 api
Why Logs Timestamp Display Matters

Having timestamps readily available when actually needed — correlating events, measuring elapsed time between log entries — is a small but valuable capability for more precise log analysis, available through this simple flag whenever that level of detail is genuinely useful.