Created
March 10, 2014 19:33
-
-
Save stavxyz/9472551 to your computer and use it in GitHub Desktop.
python logging config
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import logging | |
import socket | |
import logging | |
import logging.config | |
import logstash | |
test1 = {"version": 1, | |
"loggers": { | |
"test1": { | |
"propagate": 1, | |
"level": "DEBUG", | |
"handlers": ["test1SysLogHandler"]}}, | |
"handlers": { | |
"test1SysLogHandler": { | |
"class": "logging.handlers.SysLogHandler", | |
"formatter": "test1Formatter", | |
"level": "DEBUG", | |
"address": ("10.23.245.141", 5140)}}, | |
"formatters": { | |
"test1Formatter": { | |
"format": "%(asctime)s - %(name)s - %(levelname)s - %(message)s"}}} | |
test2 = { | |
"version": 1, | |
"loggers": { | |
"test2": { | |
"propagate": 1, | |
"level": "DEBUG", | |
"handlers": ["test2Logstash"]}}, | |
"handlers": { | |
"test2Logstash": { | |
"class": "logstash.LogstashHandler", | |
"version": 1, | |
"level": "DEBUG", | |
"host": "10.14.209.231", | |
"port": 5959}}} | |
logging.config.dictConfig(test1) | |
R = logging.getLogger('test1') | |
#R.setLevel(logging.DEBUG) | |
#test1_syslog = SysLogHandler(address=('10.14.209.231', 9299)) | |
#R.addHandler(test1_syslog) | |
# `extra` must be a dict | |
R.info("here, here is some info key=value", extra={"extrabunk":"dat bunk"}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment