Python Forum
i am getting error while writing code for exception logging - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: i am getting error while writing code for exception logging (/thread-22184.html)



i am getting error while writing code for exception logging - rkgupta51179 - Nov-02-2019

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'



RE: i am getting error while writing code for exception logging - buran - Nov-03-2019

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