Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 i am getting error while writing code for exception logging
#1
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'
buran wrote Nov-02-2019, 07:22 PM:
Please, use proper tags when post code, traceback, output, etc. This time I have added tags for you.
See BBcode help for more info.
Quote
#2
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
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Block of code, scope of variables and surprising exception arbiel 8 248 Yesterday, 07:57 PM
Last Post: arbiel
  Exception: Returned Type Mismatch Error devansing 1 119 Mar-06-2020, 07:26 PM
Last Post: ndc85430
  code not writing to projNameVal portion of code. umkc1 1 107 Feb-05-2020, 10:05 PM
Last Post: Larz60+
  Continuing code after exception palladium 1 193 Dec-14-2019, 02:43 PM
Last Post: ichabod801
  C API: Writing Executed Code to a File myanrueller 0 139 Nov-17-2019, 09:35 PM
Last Post: myanrueller
  Writing a code with 3 digit numbers while they cant contain 0 and then sum them AFKManager 2 498 Jan-13-2019, 12:00 PM
Last Post: perfringo
  Help with Code (Writing Data File) caroline_d_124 3 600 Jan-06-2019, 09:17 PM
Last Post: caroline_d_124
  During handling of the above exception, another exception occurred Skaperen 7 10,272 Dec-21-2018, 10:58 AM
Last Post: Gribouillis
  Can't find error in code but Python throws exception Sandwich_masterX 3 608 Oct-09-2018, 01:38 AM
Last Post: ichabod801
  writing bytes error qrani 4 682 Sep-22-2018, 09:00 PM
Last Post: qrani

Forum Jump:


Users browsing this thread: 1 Guest(s)