MoisesRT 62b6541f89 | 8 years ago | |
---|---|---|
logzio | 8 years ago | |
LICENSE | 9 years ago | |
README.md | 8 years ago | |
setup.cfg.py | 9 years ago | |
setup.py | 9 years ago |
This is a Python handler that sends logs in bulk over HTTPS to Logz.io. The handler uses an internal buffer, and you can choose the drain timeout as well as the number of messages to hold in the queue before the drain. Everything works in threads, so if the main program exists, the threads will continue to work until all logs are drained.
This is in BETA. We currently use this handler internally. We will provide tests soon
pip install logzio-python-handler
[handlers]
keys=LogzioHandler
[handler_LogzioHandler]
class=logzio.handler.LogzioHandler
formatter=jsonFormat
args=('token', 10, 20)
[formatters]
keys=jsonFormat
[loggers]
keys=root
[logger_root]
handlers=LogzioHandler
level=INFO
[formatter_jsonFormat]
format={ "loggerName":"%(name)s", "functionName":"%(funcName)s", "lineNo":"%(lineno)d", "levelName":"%(levelname)s", "message":"%(message)s"}
args=() arguments, by order
import logging
import logging.config
# Say i have saved my configuration under ./myconf.conf
logging.config.fileConfig('myconf.conf')
logger = logging.getLogger('superAwesomeLogzioLogger')
logger.info('Test log')
logger.warn('Warning')
try:
1/0
except:
logger.exception("Supporting exceptions too!")
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'formatters': {
'verbose': {
'format': '%(levelname)s %(asctime)s %(module)s %(process)d %(thread)d %(message)s'
},
'json': {
'format': '{ "loggerName":"%(name)s", "functionName":"%(funcName)s", "lineNo":"%(lineno)d", "levelName":"%(levelname)s", "message":"%(message)s"}'
}
},
'handlers': {
'console': {
'class': 'logging.StreamHandler',
'level': 'DEBUG',
'formatter': 'verbose'
},
'logzio': {
'class': 'logzio.handler.LogzioHandler',
'level': 'INFO',
'formatter': 'json',
'token': 'token',
'url': 'https://listener.logz.io:8071'
'logs_drain_count': 10,
'logs_drain_timeout': 5,
'logzio_type': "django"
},
},
'loggers': {
'django': {
'handlers': ['console', ],
'level': os.getenv('DJANGO_LOG_LEVEL', 'INFO')
},
'appname': {
'handlers': ['console', 'logzio'],
'level': 'INFO'
}
}
}
Change