Last active
December 12, 2015 07:58
-
-
Save DanielSzoska/4740654 to your computer and use it in GitHub Desktop.
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 | |
# 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