Add support for loading logging configuration in configure_logging function (#56340)#60384
Conversation
|
The doc is out of date, and this change will result in half the logs not going via this processor. In Airflow 3 the mechanism to configure logging has changed, and things should be implemented as a structlog processor, and user control of the full logging config is not possible anymore. Sorry. Yes this is a problem that needs addressing, but the approach in this PR is not correct so I'm going to close this PR |
|
Thanks for the review, and sorry my approach didn't match the current logging architecture in Airflow 3. This is also a good opportunity for me to learn. To align with the architecture, you mentioned using a structlog processor. Does that typically sit within a Appreciate the guidance, this review helps a lot :) |
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