Created
August 20, 2019 03:20
-
-
Save HoweChen/f395e1f828378f11220fa923f770e177 to your computer and use it in GitHub Desktop.
[console和文件同时记录log]#Python
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
| # setup the logging information | |
| import datetime | |
| today = datetime.today() | |
| logging.basicConfig(format="%(asctime)s %(levelname)s %(name)s %(message)s", | |
| datefmt="%d-%M-%Y %H:%M:%S", level=logging.DEBUG, handlers=[ | |
| logging.FileHandler(filename=f"{today}.log"), | |
| logging.StreamHandler() | |
| ]) | |
| logger = logging.getLogger() | |
| logger.info("Test") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment