Skip to content

Instantly share code, notes, and snippets.

@icedraco
Created February 6, 2017 17:19
Show Gist options
  • Save icedraco/6c393c5db52c8a88121c73adec3c6e79 to your computer and use it in GitHub Desktop.
Save icedraco/6c393c5db52c8a88121c73adec3c6e79 to your computer and use it in GitHub Desktop.
Sample logging config file for Python (load via logging.config.fileConfig('python_logging_conf.ini'))
[loggers]
keys=root, other
[logger_root]
level=DEBUG
handlers=hand01
[logger_other]
qualname=util.other
level=DEBUG
handlers=hand01
propagate=1
[handlers]
keys=hand01, hand02, hand03, hand04, hand05, hand06, hand07, hand08, hand09
[handler_hand01]
class=StreamHandler
level=NOTSET
formatter=form01
args=(sys.stdout,)
[handler_hand02]
class=FileHandler
level=DEBUG
formatter=form01
args=('python.log', 'w')
[handler_hand03]
class=handlers.SocketHandler
level=INFO
formatter=form01
args=('localhost', handlers.DEFAULT_TCP_LOGGING_PORT)
[handler_hand04]
class=handlers.DatagramHandler
level=WARN
formatter=form01
args=('localhost', handlers.DEFAULT_UDP_LOGGING_PORT)
[handler_hand05]
class=handlers.SysLogHandler
level=ERROR
formatter=form01
args=(('localhost', handlers.SYSLOG_UDP_PORT), handlers.SysLogHandler.LOG_USER)
[handler_hand06]
class=handlers.NTEventLogHandler
level=CRITICAL
formatter=form01
args=('Python Application', '', 'Application')
[handler_hand07]
class=handlers.SMTPHandler
level=WARN
formatter=form01
args=('localhost', 'from@abc', ['user1@abc', 'user2@xyz'], 'Logger Subject')
[handler_hand08]
class=handlers.MemoryHandler
level=NOTSET
formatter=form01
target=
args=(10, ERROR)
[handler_hand09]
class=handlers.HTTPHandler
level=NOTSET
formatter=form01
args=('localhost:9022', '/log', 'GET')
[formatters]
keys=form01
[formatter_form01]
format=%(asctime)s %(levelname)s %(message)s
datefmt=
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment