summary refs log tree commit diff
path: root/synapse/config/logger.py
diff options
context:
space:
mode:
authorDavid Baker <dave@matrix.org>2015-04-30 16:17:27 +0100
committerDavid Baker <dave@matrix.org>2015-04-30 16:21:38 +0100
commit054aa0d58c22ae76d3e094fc2fd6495456ffd2cf (patch)
tree5e2f589123200c2495a08a9119335025772bbeb6 /synapse/config/logger.py
parentDon't use sub queries, it makes postgres sad (diff)
downloadsynapse-054aa0d58c22ae76d3e094fc2fd6495456ffd2cf.tar.xz
Do access log using python's logging stuff, just under a separate logger name
Diffstat (limited to 'synapse/config/logger.py')
-rw-r--r--synapse/config/logger.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/synapse/config/logger.py b/synapse/config/logger.py
index 559cbe7963..077f20497a 100644
--- a/synapse/config/logger.py
+++ b/synapse/config/logger.py
@@ -83,6 +83,17 @@ class LoggingConfig(Config):
             handler.addFilter(LoggingContextFilter(request=""))
 
             logger.addHandler(handler)
+
+            if self.access_log_file:
+                access_logger = logging.getLogger('synapse.access')
+                # we log to both files by default
+                access_logger.propagate = 1
+                access_log_handler = logging.handlers.RotatingFileHandler(
+                    self.access_log_file, maxBytes=(1000 * 1000 * 100), backupCount=3
+                )
+                access_log_formatter = logging.Formatter('%(message)s')
+                access_log_handler.setFormatter(access_log_formatter)
+                access_logger.addHandler(access_log_handler)
         else:
             with open(self.log_config, 'r') as f:
                 logging.config.dictConfig(yaml.load(f))