Override base log folder by using task handler's base_log_folder#32781
Conversation
| module_name, dict_name = log_config_class.split(".") | ||
| module = importlib.import_module(module_name) | ||
| logging_config = getattr(module, dict_name) |
There was a problem hiding this comment.
Below can be used instead?
from airflow.utils.module_loading import import_string
logging_config = import_string(log_config_class)
|
Can we make the above change in the |
|
@Adaverse Thanks for your feedback. Yes I agree that we can re-use How about I just reuse these 2 functions and continue my override logic here in |
Sure looks good! |
Sorry after inspecting the code a bit I'll have to remove the use of Meanwhile, I'm adding some tests to cover the changes I made. |
|
Sort of confused by this, as I created the original issue based on issues I was having at work. When we upgraded to airflow 2, we didn’t see this problem anymore. AFAIK, we’re still using the same logging config from airflow 1. |
Fixes #23967
Original code use
log_directorydefined inairflow.cfgeven though anotherbase_log_folderis defined in logging config.This PR adds logic to attempt to override
log_directoryiflogging_config_classandbase_log_folderare both defined, and fall back to original default log directory if they don'tHow to test if it works:
breeze start-airflow --executor CeleryExecutor --backend postgres --load-example-dags --db-reset$AIRFLOW_HOME, create a directory calledconfig, and create an empty__init__.pyandlog_config.pyfile insideairflow/config_templates/airflow_local_settings.py, modifyDEFAULT_LOGGING_CONFIG[handlers][task][base_log_folder]to some other different locationsairflow/config_templates/airflow_local_settings.pyintolog_config.py/root/airflow/airflow.cfg, underloggingsection, modifylogging_config_classtolog_config.DEFAULT_LOGGING_CONFIG