Python Tutorial: Logging Basics – Logging to Files, Setting Levels, and Formatting

Python

Video is ready, Click Here to View ×


In this Python Tutorial, we will be going over the basics of logging. We will learn how to switch out our print statements for logs, change the logging level, add logs to files, and also how to change the format of those logs. Let’s get started.

Advanced Logging Video – https://youtu.be/jxmzY9soFXg
Log Record Attribute Docs: https://docs.python.org/3/library/logging.html#logrecord-attributes

The code from this video can be found…

24 thoughts on “Python Tutorial: Logging Basics – Logging to Files, Setting Levels, and Formatting

  1. Impossible to get the code working ! (even if I copy/paste from github !

    [ha@pc prog_python]$ python3 log-sample.py
    Traceback (most recent call last):
    File "log-sample.py", line 1, in <module>
    import logging
    File "/home/ha/Documents/prog_python/logging.py", line 22, in <module>
    logging.warning ('{} + {} = {}'.format(a, b, add_result))
    AttributeError: module 'logging' has no attribute 'warning'

Leave a Reply

Your email address will not be published. Required fields are marked *