Python Forum

Full Version: i am getting error while writing code for exception logging
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
import logging
import logging.config

logging.basicConfig(filename='mylog.txt', level=logging.ERROR)

logging.error("There isan error in the program.")
logging.critical("There is a problem in the design.")

logging.warning("The project isgoing slow.")
logging.info("You are a junior programmer.")
logging.debug("Line no. 10 conrains syntax error.")
ERROR:

Error:
Traceback (most recent call last): File "C:\Users\rahul\Desktop\Python-workspace\Test\error_log1.py", line 6, in <module> import logging File "C:\Users\rahul\Desktop\Python-workspace\Test\logging.py", line 9, in <module> logging.basicConfig(filename='mylog.txt', level=logging.ERROR) AttributeError: module 'logging' has no attribute 'basicConfig'
You have file with name logging.py in the same folder as your script and it override the logging module from standard library. Rename that file to something else