1
0

log.config 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. {% if not SYNAPSE_LOG_SENSITIVE %}
  45. {#
  46. If SYNAPSE_LOG_SENSITIVE is unset, then override synapse.storage.SQL to INFO
  47. so that DEBUG entries (containing sensitive information) are not emitted.
  48. #}
  49. loggers:
  50. synapse.storage.SQL:
  51. # beware: increasing this to DEBUG will make synapse log sensitive
  52. # information such as access tokens.
  53. level: INFO
  54. {% endif %}
  55. root:
  56. level: {{ SYNAPSE_LOG_LEVEL or "INFO" }}
  57. {% if LOG_FILE_PATH %}
  58. handlers: [console, buffer]
  59. {% else %}
  60. handlers: [console]
  61. {% endif %}
  62. disable_existing_loggers: false