Skip to content

Configure logging for API server#68660

Open
Abdulrehman-PIAIC80387 wants to merge 3 commits into
apache:mainfrom
Abdulrehman-PIAIC80387:fix-api-server-colored-console-log
Open

Configure logging for API server#68660
Abdulrehman-PIAIC80387 wants to merge 3 commits into
apache:mainfrom
Abdulrehman-PIAIC80387:fix-api-server-colored-console-log

Conversation

@Abdulrehman-PIAIC80387

@Abdulrehman-PIAIC80387 Abdulrehman-PIAIC80387 commented Jun 17, 2026

Copy link
Copy Markdown

The API server did not respect logging.colored_console_log. Setting AIRFLOW__LOGGING__COLORED_CONSOLE_LOG=False left 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 the colored_console_log config. #54992 fixed the Triggerer but left the API server (the second process named in #54962) unaddressed.

Fix

Call configure_logging() in airflow.api_fastapi.main, the module that both uvicorn and gunicorn import in every worker process (uvicorn runs main:app; gunicorn's worker load() does from airflow.api_fastapi.main import app). configure_logging() reads logging.colored_console_log from config, so the API server now honors it.

Design notes

  • The call is placed in the per-worker entrypoint rather than the CLI master process (_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.
  • This mirrors the approach merged in Configure logging for Triggerer #54992 for the Triggerer.

Tests

Added test_main.py asserting configure_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 UTC

Some review feedback from @pierrejeambrun is waiting on you:

  • 1 unresolved review thread(s) from @pierrejeambrun need 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.

@SameerMesiah97 SameerMesiah97 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

@potiuk potiuk added the ready for maintainer review Set after triaging when all criteria pass. label Jun 22, 2026

@pierrejeambrun pierrejeambrun left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

To remove

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:API Airflow's REST/HTTP API ready for maintainer review Set after triaging when all criteria pass.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Colored_console_log=False not affecting all Airflow processes

4 participants