Skip to content

feat(server): support optionally disabling uvicorn access logs#255

Open
fercor-cisco wants to merge 1 commit into
mainfrom
fernando.254
Open

feat(server): support optionally disabling uvicorn access logs#255
fercor-cisco wants to merge 1 commit into
mainfrom
fernando.254

Conversation

@fercor-cisco

Copy link
Copy Markdown
Contributor

Summary

Adds an access_log setting that lets embedders suppress uvicorn's built-in per-request access log, defaulting to True (no behavior change for existing users).

When agent_control_server is embedded in a host that already emits its own structured request log, uvicorn's uvicorn.access line produces a duplicate per request. The existing AGENT_CONTROL_CONFIGURE_LOGGING=false opt-out does not stop it — uvicorn's Config.configure_logging() unconditionally resets uvicorn.access to INFO. The reliable lever is uvicorn's access_log kwarg: with access_log=False, uvicorn clears the logger's handlers and sets propagate=False, so the line is never emitted.

Changes

  • config.py — add access_log: bool = _env_alias_field(True, "AGENT_CONTROL_ACCESS_LOG") to LoggingSettings (matches the configure_logging alias pattern).
  • logging_utils.py — add an access_log_enabled() helper mirroring should_configure_logging(), so main.py reads logging config via helpers (repo convention) rather than importing LoggingSettings directly.
  • main.py — pass "access_log": access_log_enabled() into uvicorn_kwargs in run().
  • Tests — update test_run_uses_settings (its fixed positional fake_run signature would otherwise break) to assert access_log is True; add test_run_disables_uvicorn_access_log_when_requested; add default/disable tests in test_config.py and test_logging_utils.py.
  • .env.example — add a Logging section documenting AGENT_CONTROL_ACCESS_LOG alongside the previously-undocumented AGENT_CONTROL_LOG_LEVEL, AGENT_CONTROL_LOG_JSON, and AGENT_CONTROL_CONFIGURE_LOGGING.

Acceptance criteria

  • New access_log setting on LoggingSettings, defaulting to True.
  • Configurable via AGENT_CONTROL_ACCESS_LOG.
  • With AGENT_CONTROL_ACCESS_LOG=false, no uvicorn.access line is emitted, whether configure_logging is on or off.
  • Error/app logging (uvicorn.error, application loggers) unaffected.
  • Documented in .env.example.

Testing

All 47 tests across the affected suites pass (test_config.py, test_main_lifespan.py, test_logging_utils.py), run against a local dev Postgres.

Notes

  • server/README.md defers config docs to https://docs.agentcontrol.dev/components/server (out of repo scope) — worth updating there separately as a follow-up.

Closes #254

🤖 Generated with Claude Code

Add an `access_log` setting on `LoggingSettings` (default `True`,
configurable via `AGENT_CONTROL_ACCESS_LOG`) and plumb it through to
`uvicorn.run(..., access_log=...)`. Setting it to `false` suppresses
uvicorn's built-in per-request access log regardless of the
`configure_logging` path, letting embedders that inject their own
request-logging middleware avoid a duplicate line per request.

Closes #254

Co-Authored-By: Claude <noreply@anthropic.com>
@codecov

codecov Bot commented Jul 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@fercor-cisco fercor-cisco left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 This review was generated by the Astra agent (claude-opus-4-8). It may contain mistakes.

Verdict: approve — Small, correct, well-tested opt-out for uvicorn access logs; defaults preserve existing behavior and the mechanism matches uvicorn's documented handling of access_log=False.

Follow-ups

Suggested follow-up work that could be tracked as Shortcut stories:

  • server/README.md:1-1: As the author notes, server config docs are hosted at docs.agentcontrol.dev/components/server (out of repo scope). The new AGENT_CONTROL_ACCESS_LOG setting (and the other logging vars now documented in .env.example) should be reflected there separately.

@fercor-cisco
fercor-cisco marked this pull request as ready for review July 24, 2026 22:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support optionally disabling uvicorn access logs

1 participant