mjpieters commented on a change in pull request #9363:
URL: https://github.com/apache/airflow/pull/9363#discussion_r517297855



##########
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

Review comment:
       This is just a reference to the list, **not a copy**. The list is 
emptied by `root_logger.removeHandler()` further down. So you end up with an 
empty list of handlers when you later try to reset.




----------------------------------------------------------------
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]


Reply via email to