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 trialmichaelangelo owildeberry
18,173 PointsLog a message with a level of DEBUG. The message can say anything you want.
Watched video several times, not sure where to go from here. =) please help
import logging
logging.basicConfig(filename='cc.log', level=logging.DEBUG)
# Write your code below here
state = 7
logging.info('state')
6 Answers
Annie Scott
27,613 Pointstask 1
import logging
logging.basicConfig(filename='cc.log', level=logging.DEBUG)
Write your code below here
logging.debug('This message should go to the log file')
hope this help, truly not in the video found docs python.org
Kenneth Love
Treehouse Guest TeacherThe prompt says to create a log message at level debug. You did logging.info()
which creates a message at level info.
Jose Luis Lopez
19,179 Pointsimport logging
logging.basicConfig(filename='cc.log', level=logging.DEBUG) logging.debug("yes")
This is how this code worked for me since I used logging.info and didn't let me pass the task
michaelangelo owildeberry
18,173 PointsI see, my thinking was that logging.info would log all levels, including DEBUG. I made the code work with logging.debug. Thanks again Kenneth, that would be radical to work together on a future project. I am also a Oregon Python-artista. =)
Annie Scott
27,613 Pointstask 2
import logging
logging.basicConfig(filename='cc.log', level=logging.DEBUG)
Write your code below here
logging.debug('This message should go to the log file') logging.warning("The French have the Grail" )
aa2179
3,133 PointsLogging works based on the level that you set and acts as the threshold for tracking events. Levels in order of severity from lowest to highest - debug, info, warning, error, critical.
Example #1:
logging.basicConfig(filename='cc.log', level=logging.DEBUG)
logging.debug('Debug message')
logging.info('Info message')
logging.warning('Warning Message')
will write all these messages to the cc.log file, since DEBUG is the lowest level
DEBUG:root:Debug message
INFO:root:Info message
WARNING:root:Warning Message
Example #2:
logging.basicConfig(filename='logger.log', level=logging.ERROR)
logging.error('Error message')
logging.critical('Critical message')
logging.warning('Warning Message')
will exclude the warning message
ERROR:root:Error message
CRITICAL:root:Critical message
Kenneth Love
Treehouse Guest TeacherKenneth Love
Treehouse Guest TeacherAt 5:03, we log a message with
logging.info()
and I bring up that.debug()
,.warn()
, etc all log messages at those levels. We also didlogging.warn()
andlogging.info()
before that. So, no, we didn't do exactlylogging.debug()
but if you were following along, it shouldn't have been that big of a jump to do.Sorry if it was confusing!
Piotr Manczak
Front End Web Development Techdegree Graduate 29,277 PointsPiotr Manczak
Front End Web Development Techdegree Graduate 29,277 PointsThanks for your time and effort. I watched video many times and spend a lot of time trying different stuff without succes. Luckly, you are with us. Thanks again.