Skip to content

Instantly share code, notes, and snippets.

@DanielSzoska
Last active December 12, 2015 07:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DanielSzoska/4740654 to your computer and use it in GitHub Desktop.
Save DanielSzoska/4740654 to your computer and use it in GitHub Desktop.
import logging
# configuration of the default standard logger - log to a file
logging.basicConfig(format='%(asctime)s %(message)s',
level=logging.DEBUG,
filename='logfile.log',
datefmt='%d.%m.%Y %H:%M:%S')
# we need an additional logger, that will log to the console
# use at main or program start
console = logging.StreamHandler()
console.setLevel(logging.INFO)
formatter = logging.Formatter('%(asctime)s %(message)s',
datefmt='%d.%m.%Y %H:%M:%S')
console.setFormatter(formatter)
logging.getLogger('').addHandler(console)
# some examples, use somewhere in the code
logging.info('info-logging-message')
logging.debug('debug-logging-message)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment