Skip to content

Instantly share code, notes, and snippets.

@jseabold
Last active August 29, 2015 13:56
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 jseabold/9314585 to your computer and use it in GitHub Desktop.
Save jseabold/9314585 to your computer and use it in GitHub Desktop.
Multiple logs in a loop
import logging
for i in range(5):
for j in range(10, 15):
logger = logging.getLogger("log_{}_{}.log".format(i, j))
handler = logging.FileHandler("log_{}_{}.log".format(i, j))
logger.setLevel(logging.INFO)
logger.addHandler(handler)
logger.info("I'm on this loop")
logger.info("It's loop {}".format(j))
logger.info("Of loop {}".format(i))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment