Skip to content

Instantly share code, notes, and snippets.

@adejones
Created October 20, 2016 11:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adejones/8286d5350bcd48fa925532b48f785536 to your computer and use it in GitHub Desktop.
Save adejones/8286d5350bcd48fa925532b48f785536 to your computer and use it in GitHub Desktop.
import logging
# change default log entry format, set filename and logging level
logging.basicConfig(level=logging.INFO, format="%(asctime)s %(levelname)s %(message)s", filename="example.log")
logging.info("Started")
logging.info("This is an example entry")
logging.debug("This line won't get logged as the log level is INFO")
logging.info("Done.")
# perform an orderly shutdown by flushing and closing all handlers; called at application exit and no further use of the logging system should be made after this call.
logging.shutdown()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment