Skip to content

Instantly share code, notes, and snippets.

@HoweChen
Created August 20, 2019 03:20
Show Gist options
  • Select an option

  • Save HoweChen/f395e1f828378f11220fa923f770e177 to your computer and use it in GitHub Desktop.

Select an option

Save HoweChen/f395e1f828378f11220fa923f770e177 to your computer and use it in GitHub Desktop.
[console和文件同时记录log]#Python
# 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