Skip to content

rust.missing_structured_logging

Observability Medium

Detects unstructured string logging instead of structured logs with fields.

Unstructured logs:

  • Hard to query — Can’t filter by field values
  • No aggregation — Can’t count by error type
  • Poor metrics — Harder to build dashboards
// ❌ Before (unstructured logging)
info!("User {} logged in from {}", user_id, ip_address);
error!("Failed to process order {}: {}", order_id, err);
// ✅ After (structured logging with tracing)
use tracing::{info, error};
info!(user_id = %user_id, ip = %ip_address, "User logged in");
error!(order_id = %order_id, error = ?err, "Failed to process order");
  • Format strings with interpolated values
  • Missing structured fields in log macros
  • Debug prints in production paths

Unfault can convert to structured tracing macros with named fields.