Prefer per-call fields for async work
extra accepts a mapping with string keys and values of type str, int, float, bool, or None. It is available on log, debug, info, warning, error, and critical.
Inline values override active log_context keys. Native metadata.key_values representations may normalize values to strings: the source-verified JSON example renders request ID 42 as "42". Check the sink’s schema rather than assuming scalar type preservation.
Keep scoped context on its thread
log_context(**fields) enriches named logger records while the scope is active on the calling thread. Holding it across an await can share context between concurrent tasks on one event-loop thread. Use per-call extra for asyncio work; task-local context remains exploratory work.
Limits per record: 64 keys, 64 UTF-8 bytes per key, 1024 UTF-8 bytes per value, and 16 KiB total serialized enrichment. Reserved metadata and stdlib LogRecord names cannot be overwritten.
Capture exception and stack payloads
exc_info accepts True, an exception instance, an exception tuple, or False/None. stack_info=True captures the current call stack. exception() defaults exception capture to True but does not accept extra.
Exception records use a versioned schema. Consumers must check EXCEPTION_SCHEMA_VERSION and the documented mismatch policy. Payloads contain sensitive messages and source paths; review them before export.