Created
June 19, 2018 03:07
-
-
Save abhi1010/786ecdc2f5e0f8bf742412b7beaefa07 to your computer and use it in GitHub Desktop.
python logging to console and file
This file contains hidden or 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 | |
FORMAT = '%(asctime)-15s %(filename)s <%(lineno)s> %(message)s' | |
logging.basicConfig( | |
filename='log-myreport.log', level=logging.DEBUG, format=FORMAT) | |
stdoutLogger = logging.StreamHandler() | |
stdoutLogger.setFormatter(logging.Formatter(logging.BASIC_FORMAT)) | |
logging.getLogger().addHandler(stdoutLogger) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment