Log Message Character Design Guide

In application development, log message design is a critical factor in operational quality. Well-sized log messages speed up root cause analysis during incidents and improve day-to-day monitoring efficiency. Overly verbose logs inflate storage costs and bury important information. This article covers recommended message lengths by log level, structured logging design, and the balance between cost and readability.

Recommended Length by Log Level

Log LevelMessage LengthContext InfoUse Case
FATAL / CRITICAL80–200 charsDetailed (incl. stack trace)System-stopping failures
ERROR60–150 charsDetailed (error code, impact)Processing failures, exceptions
WARN40–100 charsModerate (thresholds, values)Potential issues, deprecations
INFO30–80 charsMinimal (process name, result)Normal operation records
DEBUG20–60 charsVariable values, state changesDevelopment and debugging
TRACE10–40 charsFunction inputs/outputsDetailed tracing

Including metadata (timestamp, level, source file, line number), a single log line should generally stay within 200–500 characters.

The Scale of Logging at Big Tech

Netflix reportedly processes hundreds of terabytes of log data per day. Google's internal logging system is said to handle billions of log lines per second. At this scale, adding just 10 bytes per log line can increase annual storage costs by hundreds of thousands of dollars. This is why SRE teams at large-scale services are meticulous about log message length.

Structured Logging Format Design

Modern log management favors JSON-formatted structured logs over plain text. Structured logs are easier to search and filter, and integrate well with tools like CloudWatch Logs Insights and Elasticsearch.

FieldLength GuideContent
message30–150 charsHuman-readable message body
error_code5–20 charse.g., ERR_DB_CONN
request_id36 charsUUID v4 format
user_id10–50 charsUser identifier
service_name5–30 charsMicroservice name
duration_ms1–10 charsProcessing time in milliseconds

A typical structured log record should be 500 bytes to 2 KB. ERROR-level logs with stack traces may reach 5–10 KB, but normal logs should target under 1 KB.

Storage Cost Considerations

Good vs. Bad Log Messages

SRE Best Practices

Log Retention Guidelines

Log TypeRetentionReason
Access Logs90 days – 1 yearSecurity audits, intrusion investigation
Application Logs30–90 daysIncident investigation, performance analysis
Debug Logs7–14 daysRecent issue investigation only
Audit Logs1–7 yearsRegulatory compliance

Conclusion

Log message length should range from 20–200 characters depending on the log level. For structured logs, target under 1 KB per record and balance storage costs with readability. Messages that clearly convey "what happened" and "why" are the foundation of operational excellence. Use Character Counter to verify your log message lengths.