Course contentsShow
← System Design
Lesson 1139 of 1,91929. Observability: LoggingFree lesson

Standard Log Fields

Essential fields every structured log should contain: timestamp, level, message, service, and host.

Standard Log Fields

You'll learn which fields every structured log should include to make them useful, searchable, and actionable.

The Core Set of Log Fields

When you move to structured logging (using JSON or similar formats), you gain immense power—but only if your logs are consistent. Think of standard log fields as the "address book format" for your logs: everyone uses the same fields in the same way, so you can search, filter, and analyze logs across all your services.

Here are the essential fields every structured log should contain:

timestamp

When did this event occur? Use ISO 8601 format with timezone (e.g., 2024-01-15T10:23:45.123Z). This is your primary sorting key and critical for correlating events across services.

level

The severity: DEBUG, INFO, WARN, ERROR, FATAL. This lets you filter noise and focus on problems during incidents.

message

A human-readable description of what happened. Keep it clear and contextual: "User login failed" is better than "Error in handler."

service

Which service emitted this log? In a microservices architecture with dozens of services, this field is essential for filtering logs to one system.

host

Which server or container generated this log? When debugging, you often need to know if a problem affects one instance or all of them.

Why Standardization Matters

Without these fields, you're back to grepping through unstructured text. With them, you can query: "Show me all ERROR logs from the payment-service in the last hour on host-7" in seconds.

Key Takeaway: Every structured log should contain at minimum: timestamp, level, message, service, and host—these five fields make logs searchable, filterable, and actionable across your entire system.