summary refs log tree commit diff
diff options
context:
space:
mode:
authorMark Haines <mark.haines@matrix.org>2016-12-30 15:13:49 +0000
committerMark Haines <mark.haines@matrix.org>2016-12-30 15:13:49 +0000
commitf576c34594e5bc6eaa83b32864a02f42aeaf0761 (patch)
tree27e9aff6be00ceffd365e9854ea82b117589b97b
parentMerge branch 'release-v0.18.6' into develop (diff)
parentMerge pull request #1731 from matrix-org/markjh/logging-memleak (diff)
downloadsynapse-f576c34594e5bc6eaa83b32864a02f42aeaf0761.tar.xz
Merge remote-tracking branch 'origin/release-v0.18.6' into develop
-rw-r--r--synapse/config/logger.py16
1 files changed, 13 insertions, 3 deletions
diff --git a/synapse/config/logger.py b/synapse/config/logger.py
index ec72c95436..63e69a7e0c 100644
--- a/synapse/config/logger.py
+++ b/synapse/config/logger.py
@@ -15,7 +15,7 @@
 
 from ._base import Config
 from synapse.util.logcontext import LoggingContextFilter
-from twisted.python.log import PythonLoggingObserver
+from twisted.logger import globalLogBeginner, STDLibLogObserver
 import logging
 import logging.config
 import yaml
@@ -180,5 +180,15 @@ def setup_logging(log_config=None, log_file=None, verbosity=None):
         with open(log_config, 'r') as f:
             logging.config.dictConfig(yaml.load(f))
 
-    observer = PythonLoggingObserver()
-    observer.start()
+    # It's critical to point twisted's internal logging somewhere, otherwise it
+    # stacks up and leaks kup to 64K object;
+    # see: https://twistedmatrix.com/trac/ticket/8164
+    #
+    # Routing to the python logging framework could be a performance problem if
+    # the handlers blocked for a long time as python.logging is a blocking API
+    # see https://twistedmatrix.com/documents/current/core/howto/logger.html
+    # filed as https://github.com/matrix-org/synapse/issues/1727
+    #
+    # However this may not be too much of a problem if we are just writing to a file.
+    observer = STDLibLogObserver()
+    globalLogBeginner.beginLoggingTo([observer])