Logging handler to send logs to your OpenSearch cluster with bulk SSL. Forked from https://github.com/logzio/logzio-python-handler
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

57 lines
1.4 KiB

  1. # Logz.io python handler
  2. Python handler that sends logs in bulk over https to logz.io. The handler use an internal buffer, and you can choose the drain timeout, and the number of messages to hold in queue before drain. Everything is working in threads, and they would exit after completing draining all the logs if the main program exits.
  3. ## Installation
  4. ```bash
  5. pip install logzio-python-handler
  6. ```
  7. ## Python configuration
  8. #### Config File
  9. ```
  10. [handlers]
  11. keys=LogzioHandler
  12. [handler_LogzioHandler]
  13. class=logzio.handler.LogzioHandler
  14. formatter=jsonFormat
  15. args=('token', 10, 20)
  16. [formatters]
  17. keys=jsonFormat
  18. [loggers]
  19. keys=root
  20. [logger_root]
  21. handlers=LogzioHandler
  22. level=INFO
  23. [formatter_jsonFormat]
  24. format={ "loggerName":"%(name)s", "functionName":"%(funcName)s", "lineNo":"%(lineno)d", "levelName":"%(levelname)s", "message":"%(message)s"}
  25. ```
  26. *args=() arguments, by order*
  27. - Your logz.io token
  28. - Number of logs to keep in buffer before draining
  29. - Time to wait before draining, regardless of the previouse setting
  30. - Log type, for searching in logz.io (defaults to "python")
  31. #### Code Example
  32. ```python
  33. import logging
  34. import logging.config
  35. # Say i have saved my configuration under ./myconf.conf
  36. logging.config.fileConfig('myconf.conf')
  37. logger = logging.getLogger('superAwesomeLogzioLogger')
  38. logger.info('Test log')
  39. logger.warn('Warning')
  40. try:
  41. 1/0
  42. except:
  43. logger.exception("Supporting exceptions too!")
  44. ```
  45. ## Django configuration
  46. TBD