log.config 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. version: 1
  2. formatters:
  3. precise:
  4. {% if include_worker_name_in_log_line %}
  5. format: '{{ worker_name }} | %(asctime)s - %(name)s - %(lineno)d - %(levelname)s - %(request)s - %(message)s'
  6. {% else %}
  7. format: '%(asctime)s - %(name)s - %(lineno)d - %(levelname)s - %(request)s - %(message)s'
  8. {% endif %}
  9. handlers:
  10. {% if LOG_FILE_PATH %}
  11. file:
  12. class: logging.handlers.TimedRotatingFileHandler
  13. formatter: precise
  14. filename: {{ LOG_FILE_PATH }}
  15. when: "midnight"
  16. backupCount: 6 # Does not include the current log file.
  17. encoding: utf8
  18. # Default to buffering writes to log file for efficiency.
  19. # WARNING/ERROR logs will still be flushed immediately, but there will be a
  20. # delay (of up to `period` seconds, or until the buffer is full with
  21. # `capacity` messages) before INFO/DEBUG logs get written.
  22. buffer:
  23. class: synapse.logging.handlers.PeriodicallyFlushingMemoryHandler
  24. target: file
  25. # The capacity is the maximum number of log lines that are buffered
  26. # before being written to disk. Increasing this will lead to better
  27. # performance, at the expensive of it taking longer for log lines to
  28. # be written to disk.
  29. # This parameter is required.
  30. capacity: 10
  31. # Logs with a level at or above the flush level will cause the buffer to
  32. # be flushed immediately.
  33. # Default value: 40 (ERROR)
  34. # Other values: 50 (CRITICAL), 30 (WARNING), 20 (INFO), 10 (DEBUG)
  35. flushLevel: 30 # Flush immediately for WARNING logs and higher
  36. # The period of time, in seconds, between forced flushes.
  37. # Messages will not be delayed for longer than this time.
  38. # Default value: 5 seconds
  39. period: 5
  40. {% endif %}
  41. console:
  42. class: logging.StreamHandler
  43. formatter: precise
  44. loggers:
  45. # This is just here so we can leave `loggers` in the config regardless of whether
  46. # we configure other loggers below (avoid empty yaml dict error).
  47. _placeholder:
  48. level: "INFO"
  49. {% if not SYNAPSE_LOG_SENSITIVE %}
  50. {#
  51. If SYNAPSE_LOG_SENSITIVE is unset, then override synapse.storage.SQL to INFO
  52. so that DEBUG entries (containing sensitive information) are not emitted.
  53. #}
  54. synapse.storage.SQL:
  55. # beware: increasing this to DEBUG will make synapse log sensitive
  56. # information such as access tokens.
  57. level: INFO
  58. {% endif %}
  59. {% if SYNAPSE_LOG_TESTING %}
  60. {#
  61. If Synapse is under test, log a few more useful things for a developer
  62. attempting to debug something particularly tricky.
  63. With `synapse.visibility.filtered_event_debug`, it logs when events are (maybe
  64. unexpectedly) filtered out of responses in tests. It's just nice to be able to
  65. look at the CI log and figure out why an event isn't being returned.
  66. #}
  67. synapse.visibility.filtered_event_debug:
  68. level: DEBUG
  69. {% endif %}
  70. root:
  71. level: {{ SYNAPSE_LOG_LEVEL or "INFO" }}
  72. {% if LOG_FILE_PATH %}
  73. handlers: [console, buffer]
  74. {% else %}
  75. handlers: [console]
  76. {% endif %}
  77. disable_existing_loggers: false