mjpieters commented on a change in pull request #9363:
URL: https://github.com/apache/airflow/pull/9363#discussion_r517298025
##########
File path: airflow/cli/commands/task_command.py
##########
@@ -177,14 +177,44 @@ def task_run(args, dag=None):
ti.init_run_context(raw=args.raw)
hostname = get_hostname()
+
print(f"Running {ti} on host {hostname}")
if args.interactive:
_run_task_by_selected_method(args, dag, ti)
else:
- with redirect_stdout(StreamLogWriter(ti.log, logging.INFO)), \
- redirect_stderr(StreamLogWriter(ti.log, logging.WARN)):
- _run_task_by_selected_method(args, dag, ti)
+ if settings.DONOT_MODIFY_HANDLERS:
+ with redirect_stdout(StreamLogWriter(ti.log, logging.INFO)), \
+ redirect_stderr(StreamLogWriter(ti.log, logging.WARN)):
+ _run_task_by_selected_method(args, dag, ti)
+ else:
+ # Get all the Handlers from 'airflow.task' logger
+ # Add these handlers to the root logger so that we can get logs
from
+ # any custom loggers defined in the DAG
+ airflow_logger_handlers =
logging.getLogger('airflow.task').handlers
+ root_logger = logging.getLogger()
+ root_logger_handlers = root_logger.handlers
+
+ # Remove all handlers from Root Logger to avoid duplicate logs
+ for handler in root_logger_handlers:
+ root_logger.removeHandler(handler)
+
+ for handler in airflow_logger_handlers:
+ root_logger.addHandler(handler)
+ root_logger.setLevel(logging.getLogger('airflow.task').level)
Review comment:
The root log level is never restored.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]