Configure logging for API server#68660
Open
Abdulrehman-PIAIC80387 wants to merge 3 commits into
Open
Conversation
SameerMesiah97
left a comment
Contributor
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
Member
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. | |||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.