Why this matters
Contextual logs speed up incident triage and correlation.
Log errors with operation name and identifiers (e.g., userId, orderId) using structured context.
Contextual logs speed up incident triage and correlation.
Side-by-side examples engineers can pattern-match during review.
error_log($e->getMessage());$logger->error('payment failed', ['op'=>'charge','userId'=>$userId,'orderId'=>$orderId,'exception'=>$e]);error_log($e)$logger->error('x', ['id'=>$id,'e'=>$e])From the same buckets as this rule.
Never emit Primary Account Number (PAN) or Sensitive Authentication Data (SAD: CVV/CVC, full track data, PIN) to application or audit logs. Per PCI DSS 4.0 Req. 3 and 10, always mask PAN as first6last4 and fully redact SAD before logging.