log.config 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. version: 1
  2. formatters:
  3. precise:
  4. {% if worker_name %}
  5. format: '%(asctime)s - worker:{{ worker_name }} - %(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. This means that
  19. # there will be a delay for INFO/DEBUG logs to get written, but WARNING/ERROR
  20. # logs will still be flushed immediately.
  21. buffer:
  22. class: logging.handlers.MemoryHandler
  23. target: file
  24. # The capacity is the number of log lines that are buffered before
  25. # being written to disk. Increasing this will lead to better
  26. # performance, at the expensive of it taking longer for log lines to
  27. # be written to disk.
  28. capacity: 10
  29. flushLevel: 30 # Flush for WARNING logs as well
  30. {% endif %}
  31. console:
  32. class: logging.StreamHandler
  33. formatter: precise
  34. loggers:
  35. synapse.storage.SQL:
  36. # beware: increasing this to DEBUG will make synapse log sensitive
  37. # information such as access tokens.
  38. level: INFO
  39. root:
  40. level: {{ SYNAPSE_LOG_LEVEL or "INFO" }}
  41. {% if LOG_FILE_PATH %}
  42. handlers: [console, buffer]
  43. {% else %}
  44. handlers: [console]
  45. {% endif %}
  46. disable_existing_loggers: false