1
0

sample_log_config.yaml 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. # Log configuration for Synapse.
  2. #
  3. # This is a YAML file containing a standard Python logging configuration
  4. # dictionary. See [1] for details on the valid settings.
  5. #
  6. # Synapse also supports structured logging for machine readable logs which can
  7. # be ingested by ELK stacks. See [2] for details.
  8. #
  9. # [1]: https://docs.python.org/3.7/library/logging.config.html#configuration-dictionary-schema
  10. # [2]: https://matrix-org.github.io/synapse/latest/structured_logging.html
  11. version: 1
  12. formatters:
  13. precise:
  14. format: '%(asctime)s - %(name)s - %(lineno)d - %(levelname)s - %(request)s - %(message)s'
  15. handlers:
  16. file:
  17. class: logging.handlers.TimedRotatingFileHandler
  18. formatter: precise
  19. filename: /var/log/matrix-synapse/homeserver.log
  20. when: midnight
  21. backupCount: 3 # Does not include the current log file.
  22. encoding: utf8
  23. # Default to buffering writes to log file for efficiency.
  24. # WARNING/ERROR logs will still be flushed immediately, but there will be a
  25. # delay (of up to `period` seconds, or until the buffer is full with
  26. # `capacity` messages) before INFO/DEBUG logs get written.
  27. buffer:
  28. class: synapse.logging.handlers.PeriodicallyFlushingMemoryHandler
  29. target: file
  30. # The capacity is the maximum number of log lines that are buffered
  31. # before being written to disk. Increasing this will lead to better
  32. # performance, at the expensive of it taking longer for log lines to
  33. # be written to disk.
  34. # This parameter is required.
  35. capacity: 10
  36. # Logs with a level at or above the flush level will cause the buffer to
  37. # be flushed immediately.
  38. # Default value: 40 (ERROR)
  39. # Other values: 50 (CRITICAL), 30 (WARNING), 20 (INFO), 10 (DEBUG)
  40. flushLevel: 30 # Flush immediately for WARNING logs and higher
  41. # The period of time, in seconds, between forced flushes.
  42. # Messages will not be delayed for longer than this time.
  43. # Default value: 5 seconds
  44. period: 5
  45. # A handler that writes logs to stderr. Unused by default, but can be used
  46. # instead of "buffer" and "file" in the logger handlers.
  47. console:
  48. class: logging.StreamHandler
  49. formatter: precise
  50. loggers:
  51. synapse.storage.SQL:
  52. # beware: increasing this to DEBUG will make synapse log sensitive
  53. # information such as access tokens.
  54. level: INFO
  55. twisted:
  56. # We send the twisted logging directly to the file handler,
  57. # to work around https://github.com/matrix-org/synapse/issues/3471
  58. # when using "buffer" logger. Use "console" to log to stderr instead.
  59. handlers: [file]
  60. propagate: false
  61. root:
  62. level: INFO
  63. # Write logs to the `buffer` handler, which will buffer them together in memory,
  64. # then write them to a file.
  65. #
  66. # Replace "buffer" with "console" to log to stderr instead. (Note that you'll
  67. # also need to update the configuration for the `twisted` logger above, in
  68. # this case.)
  69. #
  70. handlers: [buffer]
  71. disable_existing_loggers: false