[Solved] Python NameError: name 'logging' is not defined
Python NameError: name 'logging' is not defined
When you try Python Logging for the first time, you might get the following error echoed to the console.
Traceback (most recent call last):
File "example.py", line 2, in <module>
logging.basicConfig(format=FORMAT)
NameError: name 'logging' is not defined
This NameError: name 'logging' is not defined, is thrown when you forget to import logging module but use it in your python program.
Solution
To solve the Python "NameError: name 'logging' is not defined", include the import statement for logging module before you are actually using the logging module.
import logging
The solution is same for any module, which you may have used, but not imported at the start of program.
Summary
In this tutorial of Python Examples, we learned how to solve Python NameError: name 'logging' is not defined.