Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialMUZ140920 Kudakwashe Murungu
6,316 Pointslogging.info
import logging
logging.warn("Oh! No!")
logging.basicConfig(filename = "config.log", level = logging.DEBUG)
name = input("Type in your name:" )
logging.info("The user's name is ".format(name))
Im trying to log the typed in name but the file "config.log" is not being created, i bet if that line of my code is executing as intended. What should I do. Want to run this simple code to grasp the logging concept
2 Answers
karis hutcheson
7,036 PointsIt looks like you need to configure your log file for use BEFORE you try to log any messages ( I.E. logging.warn(str) ). I just moved that line from the top to just after the logging.basicConfig() and it created it just fine.
MUZ140920 Kudakwashe Murungu
6,316 Pointsthanks karis hutcheson I also found out that it might also have been the problem that I was running it using the PyScripter instead of using the native Python IDE.