Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Change the default log config to reduce disk I/O and storage #8040

Merged
merged 11 commits into from
Aug 11, 2020
1 change: 1 addition & 0 deletions changelog.d/8040.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Change the default log config to reduce disk I/O and storage for new servers.
19 changes: 15 additions & 4 deletions docs/sample_log_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,24 @@ filters:

handlers:
file:
class: logging.handlers.RotatingFileHandler
class: logging.handlers.TimedRotatingFileHandler
formatter: precise
filename: /var/log/matrix-synapse/homeserver.log
maxBytes: 104857600
backupCount: 10
when: midnight
backupCount: 3 # Does not include the current log file.
filters: [context]
encoding: utf8

# Default to buffering writes to log file for efficiency. This means that
# will be a delay for WARNING/INFO/DEBUG logs to get written, but ERROR
# logs will still be flushed immediately.
buffer:
richvdh marked this conversation as resolved.
Show resolved Hide resolved
class: logging.handlers.MemoryHandler
formatter: precise
erikjohnston marked this conversation as resolved.
Show resolved Hide resolved
level: DEBUG
erikjohnston marked this conversation as resolved.
Show resolved Hide resolved
target: file
capacity: 100
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I kind of wonder if 100 is a bit extreme here for a new server?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as in, too high? maybe a bit.

probably worth adding a comment here saying what the number means, so people can tweak it if they want.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, even jki.re logs at less than 30 lines a second so a brand new server would probably not actually flush very often at all, which I can imagine will cause confusion. I'm somewhat tempted to lower it to something like ten, which would still be a huge improvement.


console:
richvdh marked this conversation as resolved.
Show resolved Hide resolved
class: logging.StreamHandler
formatter: precise
Expand All @@ -38,6 +49,6 @@ loggers:

root:
level: INFO
handlers: [file, console]
handlers: [buffer, console]
erikjohnston marked this conversation as resolved.
Show resolved Hide resolved

disable_existing_loggers: false
19 changes: 15 additions & 4 deletions synapse/config/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,24 @@

handlers:
file:
class: logging.handlers.RotatingFileHandler
class: logging.handlers.TimedRotatingFileHandler
formatter: precise
filename: ${log_file}
maxBytes: 104857600
backupCount: 10
when: midnight
backupCount: 3 # Does not include the current log file.
filters: [context]
encoding: utf8

# Default to buffering writes to log file for efficiency. This means that
# will be a delay for WARNING/INFO/DEBUG logs to get written, but ERROR
# logs will still be flushed immediately.
buffer:
class: logging.handlers.MemoryHandler
formatter: precise
level: DEBUG
target: file
capacity: 100

console:
class: logging.StreamHandler
formatter: precise
Expand All @@ -82,7 +93,7 @@

root:
level: INFO
handlers: [file, console]
handlers: [buffer, console]

disable_existing_loggers: false
"""
Expand Down