Skip to content

typescript.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)
console.log(`User ${userId} logged in from ${ip}`);
console.error(`Failed to process order ${orderId}: ${error}`);
// ✅ After (structured logging)
import pino from 'pino';
const logger = pino();
logger.info({ userId, ip }, 'User logged in');
logger.error({ orderId, err: error }, 'Failed to process order');
  • Template literals in console.log
  • Missing structured logger usage
  • Debug prints with interpolated values

Unfault can convert to structured logging with pino or winston.