Created
March 31, 2020 04:17
-
-
Save easternnl/d8babe49b3fb7091e233701363091882 to your computer and use it in GitHub Desktop.
Python logging to file and to console - as in https://stackoverflow.com/a/46098711
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 | |
# remove '%(created)f' to avoid logging the timestamp in epoch | |
logging.basicConfig(level='INFO', | |
format='%(asctime)s %(created)f %(message)s', | |
handlers=[ | |
logging.FileHandler(datetime.now().strftime(testrun + ".log")), | |
logging.StreamHandler() | |
]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment