Configure logging for API server - #68660
Conversation
SameerMesiah97
left a comment
There was a problem hiding this comment.
This seems reasonable but since this PR targets user-facing observability, I think it would be best if you provided screenshots (or log snippets) illustrating the issue you described i.e. 'API server emitting ANSI color escape sequences'. As well as what the logs look like after your fix.
pierrejeambrun
left a comment
There was a problem hiding this comment.
One blocker bellow.
Also screenshot of before / after of the tmux session would be welcome.
| @@ -0,0 +1 @@ | |||
| The API server now respects the ``logging.colored_console_log`` setting, so colored console output can be disabled there as for other components. | |||
|
@Abdulrehman-PIAIC80387 I've removed the Note: This comment was drafted by an AI-assisted triage tool and may contain mistakes. If you have questions, an Apache Airflow maintainer — a real person — is happy to help. We use this two-stage triage process so that our maintainers' limited time is spent where it matters most: the conversation with you. |
The API server did not respect
logging.colored_console_log. SettingAIRFLOW__LOGGING__COLORED_CONSOLE_LOG=Falseleft the API server emitting ANSI color escape sequences, which are hard to read in log aggregators that don't render colors.The root cause is the same one #54992 fixed for the Triggerer: the process never called
configure_logging(), so structlog fell back to its default (colors=True) and ignored thecolored_console_logconfig. #54992 fixed the Triggerer but left the API server (the second process named in #54962) unaddressed.Fix
Call
configure_logging()inairflow.api_fastapi.main, the module that both uvicorn and gunicorn import in every worker process (uvicorn runsmain:app; gunicorn's workerload()doesfrom airflow.api_fastapi.main import app).configure_logging()readslogging.colored_console_logfrom config, so the API server now honors it.Design notes
_run_api_server) on purpose: uvicorn/gunicorn load the app independently in each worker, so configuring logging only in the master would not reach the worker processes that actually emit the request/app logs.Tests
Added
test_main.pyassertingconfigure_logging()is invoked when the worker entrypoint is loaded.closes: #54962
Important
🛠️ Maintainer triage note for @Abdulrehman-PIAIC80387 · by
@potiuk· 2026-07-02 17:46 UTCSome review feedback from
@pierrejeambrunis waiting on you:@pierrejeambrunneed a reply or a fix.The ball is in your court — you've been assigned to this PR. Reply or push a fix in each thread, then mark them resolved.
Automated triage — may be imperfect; a maintainer takes the next look.