Node.js Structured Application Logging Schema for Healthtech Request Trace Correlation
A healthtech notification can be clinically important without its application log containing any clinical data. That constraint changes the design: log an immutable sequence of delivery decisions and attempts, join it with request and trace context, and treat patient content as forbidden input. TL;DR: emit one JSON event for each durable state transition and delivery attempt. Include a generated…
Healthtech notification logs must focus on immutable sequence of delivery decisions and attempts. Emit one JSON event per durable state transition and delivery attempt. Include generated request ID, W3C trace ID, tenant and actor references, notification and attempt IDs, channel, outcome, error class, retry state, and schema version.
Never log sensitive information like patient content or access tokens. Structured SaaS application logs should record inbound request and its asynchronous notification lifecycle. Inbound request is just the start. API may accept scheduling command, commit work, and return before queue consumer processes it. Logs should share same notification ID while each physical delivery gets distinct attempt ID.
Request and trace IDs describe execution context, not business identifiers. Logs do not assign cause, but preserve evidence to test causes against queue and provider records. Log event envelope includes fields like event name, timestamp, notification ID, attempt ID, request ID, trace ID, tenant ID, actor ID, channel, outcome, error class, retry count, and version.
Use transactional outbox to ensure durable state change before logging. Use monotonically increasing version for database aggregate changes. Apply redaction before JSON serialization to prevent secrets from entering logs.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.