JSON logs no longer include levelname, Datadog status mapping breaks
Bug Description
- PR #3199 switched the CLI logging to a custom JsonFormatter (livekit-agents/livekit/agents/cli/log.py).
- That formatter only copies fields referenced in logging.PercentStyle.default_format, plus two hard- coded keys (level and name). It never emits the standard levelname.
- The formatter also drops levelname from extras via _RESERVED_ATTRS, so applications can’t re-add it in handlers.
- Result: production JSON logs now only contain level, not levelname. Datadog (and any tooling that
expects the canonical Python field) can’t determine log status anymore.
- As a workaround, we added ad hoc remapper logic to look at level field, but not in canonical way.
Expected Behavior
levelname is still in output json record
Reproduction Steps
Upgrade to 1.3.0+, then run agent with prod environment and json logger, and configure logging override as below
logging.PercentStyle.default_format = (
"%(levelname)s %(message)s %(processName) %(threadName)s"
)
observe that levelname is not present in the json output
Operating System
Linux
Models Used
No response
Package Versions
livekit-agents=1.3.2
Session/Room/Call IDs
No response
Proposed Solution
Always include the levelname attribute in JSON output (the previous dependency did this by default), or provide a supported hook to restore it across processes. Otherwise every consumer has to monkeypatch json formatter before app runs, which is brittle.
Additional Context
No response
Screenshots and Recordings
No response
does levelname exist in the json logs before agents 1.3? I tested with 1.2.18 and it's "level": "INFO".
does
levelnameexist in the json logs before agents 1.3? I tested with 1.2.18 and it's"level": "INFO".
It does, you need to override the default formatting as below to expose it in final json.
logging.PercentStyle.default_format = (
"%(levelname)s %(message)s %(processName) %(threadName)s"
)
But this is not working now after 1.2.18.
@longcw Any update here?
@longcw A friendly ping here.
the issue is that the setting of logging.PercentStyle.default_format is not used, fixed in https://github.com/livekit/agents/pull/4169