Skip to content

Instantly share code, notes, and snippets.

@proffalken
Created November 22, 2013 14:36
Show Gist options
  • Save proffalken/7600818 to your computer and use it in GitHub Desktop.
Save proffalken/7600818 to your computer and use it in GitHub Desktop.
import sys
import logging.config
import logging
import os.path
LOGGING_CONF=os.path.join(os.path.dirname(__file__),
"logging.ini")
logging.config.fileConfig(LOGGING_CONF)
fallthrough = logging.getLogger("root")
childlog = logging.getLogger("child")
childlog.error("Child Error")
fallthrough.info("Root info")
[loggers]
keys = root, child
[handlers]
keys = watchedfile
[formatters]
keys = default
[logger_root]
qualname = root
level = DEBUG
handlers = watchedfile
[logger_child]
qualname = child
level = WARNING
handlers = watchedfile
propagate = 0
# Our default handler to write all messages direct to disk
[handler_watchedfile]
class = handlers.WatchedFileHandler
args = ('test.log',)
formatter = default
[formatter_default]
datefmt = %Y-%m-%d %H:%M:%S
args = (datefmt=datefmt)
format = %(asctime)s.%(msecs)03d %(process)d %(levelname)s %(name)s %(message)s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment