From 4cea1b7d332808dbd981ab868ffb6e5df68eda33 Mon Sep 17 00:00:00 2001 From: Matt Traynham Date: Mon, 30 Mar 2026 09:25:50 -0400 Subject: [PATCH] Add flag for logging tasks to stdout --- airflow-core/src/airflow/config_templates/config.yml | 10 ++++++++++ airflow-core/src/airflow/executors/local_executor.py | 1 + .../celery/executors/celery_executor_utils.py | 1 + 3 files changed, 12 insertions(+) diff --git a/airflow-core/src/airflow/config_templates/config.yml b/airflow-core/src/airflow/config_templates/config.yml index 2f1c63a21c16c..7167064df5001 100644 --- a/airflow-core/src/airflow/config_templates/config.yml +++ b/airflow-core/src/airflow/config_templates/config.yml @@ -1076,6 +1076,16 @@ logging: type: boolean example: ~ default: "False" + task_log_to_stdout: + description: | + When True, task log messages are duplicated to the worker process's stdout + in addition to the task log file (and any configured remote log handler). + This is useful for container-based deployments where a log shipper (e.g. + CloudWatch agent, Fluentd, Fluent Bit) captures stdout. + version_added: 3.2.1 + type: boolean + example: "True" + default: "False" color_log_error_keywords: description: | A comma separated list of keywords related to errors whose presence should display the line in red diff --git a/airflow-core/src/airflow/executors/local_executor.py b/airflow-core/src/airflow/executors/local_executor.py index 9b5939a0bd2e7..e1127c22a805c 100644 --- a/airflow-core/src/airflow/executors/local_executor.py +++ b/airflow-core/src/airflow/executors/local_executor.py @@ -149,6 +149,7 @@ def _execute_work(log: Logger, workload: workloads.ExecuteTask, team_conf) -> No token=workload.token, server=team_conf.get("core", "execution_api_server_url", fallback=default_execution_api_server), log_path=workload.log_path, + subprocess_logs_to_stdout=team_conf.getboolean("logging", "task_log_to_stdout", fallback=False), ) diff --git a/providers/celery/src/airflow/providers/celery/executors/celery_executor_utils.py b/providers/celery/src/airflow/providers/celery/executors/celery_executor_utils.py index 6ac9ce1902974..10fdb96c1ef6e 100644 --- a/providers/celery/src/airflow/providers/celery/executors/celery_executor_utils.py +++ b/providers/celery/src/airflow/providers/celery/executors/celery_executor_utils.py @@ -223,6 +223,7 @@ def execute_workload(input: str) -> None: token=workload.token, server=conf.get("core", "execution_api_server_url", fallback=default_execution_api_server), log_path=workload.log_path, + subprocess_logs_to_stdout=conf.getboolean("logging", "task_log_to_stdout", fallback=False), ) elif isinstance(workload, workloads.ExecuteCallback): success, error_msg = execute_callback_workload(workload.callback, log)