Add support for loading logging configuration in configure_logging function (#56340) #60384
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.
closes: #56340
Why
The user configured a custom logging handler in Airflow by following this doc.
It works in a direct Python test, but it does not work when setting
logging_config_class.How
It lacks the
load_logging_configstep in theconfigure_loggingfunction; adding it resolves this issue.airflow/task-sdk/src/airflow/sdk/log.py
Line 96 in 67c95c3
What
Step 1: Setup
Here are the settings I used to reproduce this issue locally:
files/airflow-breeze-config/environment_variables.env(Click to expand)files/config/clickhouse_logging.py(Click to expand)files/config/log_config.py(Click to expand)files/dags/repro_logging_config_class.py(Click to expand)Step 2: Before the fix - Reproducing the issue
First, make sure the Airflow config has the correct value:
I ran this command in the container, and it wrote a line to
logs/clickhouse_handler.logas expected:logs/clickhouse_handler.log{"ts": 1768007319.4109492, "logger": "airflow.task", "level": "INFO", "message": "direct python handler test"}However, when I triggered the DAG, nothing was written to the log file, and the UI logs showed that the handler had not been loaded from the config.
Step 3: After the fix
After the fix, it works as expected and the config is loaded:
It also wrote logs to
logs/clickhouse_handler.log:Was generative AI tooling used to co-author this PR?
Generated-by: GPT5.2 following the guidelines