Skip to content

Instantly share code, notes, and snippets.

@starlightsys
Created May 13, 2014 11:18
Show Gist options
  • Save starlightsys/cca82963368800015e5c to your computer and use it in GitHub Desktop.
Save starlightsys/cca82963368800015e5c to your computer and use it in GitHub Desktop.
Example of using the Python logging library.
[loggers]
keys=root
[handlers]
keys=consoleHandler,fileHandler
[formatters]
keys=simpleFormatter
[logger_root]
level=NOTSET
handlers=fileHandler
[handler_fileHandler]
class=FileHandler
level=DEBUG
formatter=simpleFormatter
args=("log/debug.log", "a")
[handler_consoleHandler]
class=StreamHandler
level=DEBUG
formatter=simpleFormatter
args=(sys.stdout,)
[formatter_simpleFormatter]
format=%(asctime)s - %(name)s - %(levelname)s - %(message)s
datefmt=
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import logging, logging.config
logging.config.fileConfig( "config/logging.conf" )
logger = logging.getLogger( __name__ )
# ... rest of the program
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment