summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--tests/test_utils/logging_setup.py17
1 files changed, 12 insertions, 5 deletions
diff --git a/tests/test_utils/logging_setup.py b/tests/test_utils/logging_setup.py
index 51a197a8c6..a75a43bb03 100644
--- a/tests/test_utils/logging_setup.py
+++ b/tests/test_utils/logging_setup.py
@@ -13,6 +13,7 @@
 # limitations under the License.
 import logging
 import os
+import sys
 
 import twisted.logger
 
@@ -35,7 +36,8 @@ class ToTwistedHandler(logging.Handler):
 def setup_logging():
     """Configure the python logging appropriately for the tests.
 
-    (Logs will end up in _trial_temp.)
+    Logs will end up in _trial_temp. Exceptions are additionally
+    logged to stderr.
     """
     root_logger = logging.getLogger()
 
@@ -44,11 +46,16 @@ def setup_logging():
         "%(levelname)s - %(request)s - %(message)s"
     )
 
-    handler = ToTwistedHandler()
+    to_twisted_handler = ToTwistedHandler()
     formatter = logging.Formatter(log_format)
-    handler.setFormatter(formatter)
-    handler.addFilter(LoggingContextFilter())
-    root_logger.addHandler(handler)
+    to_twisted_handler.setFormatter(formatter)
+    to_twisted_handler.addFilter(LoggingContextFilter())
+    root_logger.addHandler(to_twisted_handler)
+
+    exception_handler = logging.StreamHandler(sys.stderr)
+    exception_handler.setLevel(logging.ERROR)
+    exception_handler.setFormatter(formatter)
+    root_logger.addHandler(exception_handler)
 
     log_level = os.environ.get("SYNAPSE_TEST_LOG_LEVEL", "ERROR")
     root_logger.setLevel(log_level)