Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 import logging not working
#1
when i run my code it says there is somthing wrong whit import logging and thus the cod dose not work

import logging
#import time
#import mylib


# DEBUG: Detailed information, typical of intrest

# INFO: Confirmation that things are working as expected

# WARNINGS:  An indication that somthing unexpected happened, or indicative of any problems

# ERORR: Due to a more serious problem, the softwear hace not been abble to perform a funktion

# CRITICAL: A incidcation of a serius error
logging.basicConfig(filename='test.log', level=logging.DEBUG,
    format='%(asctime)s:%(levelname)s:%(message)s')


#class Logging:
    #def __init__(self, battery, charge_of_battery):
        #self.battery = battery
        #self.charge_of_battery = charge_of_battery

        #logging.debug('battery log:')

    #def state(self):
        #return '{}.{} battery lvl->'.format(self.)

logg_1 = 'error error', '123v2ecwadcsa212'

#time.sleep( 10 )
logging.debug('battery log: {}'.format(logg_1))
This is the error is what is what im geting when i run the code
Error:
Traceback (most recent call last): File "H:\New folder\logging.py", line 1, in <module> import logging File "H:\New folder\logging.py", line 15, in <module> logging.basicConfig(filename='test.log', level=logging.DEBUG, AttributeError: module 'logging' has no attribute 'basicConfig'
Quote
#2
your own script is named logging.py, thus overriding the module with that name from Standard Library. Rename your script.
Quote
#3
Im still getting this
Error:
Traceback (most recent call last): File "H:\New folder\log_test1.py", line 1, in <module> import logging ImportError: bad magic number in 'logging': b'\x03\xf3\r\n'
Quote
#4
Check this for the solution
https://stackoverflow.com/a/514395/4046632
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  logging messages ahead of print messages vindo 6 301 Jun-18-2019, 02:45 PM
Last Post: vindo
  module logging posting randomly DJ_Qu 2 144 May-14-2019, 06:41 AM
Last Post: DJ_Qu
  logging: child module unable to get parent config jerryxiao 3 231 Apr-09-2019, 04:17 AM
Last Post: jerryxiao
  Configure a logging.config ytigiev 0 186 Feb-15-2019, 06:06 AM
Last Post: ytigiev
  CSV import is not working gehrenfeld 7 410 Dec-12-2018, 12:26 PM
Last Post: gehrenfeld
  Logging in python saisankalpj 1 401 Nov-12-2018, 05:00 PM
Last Post: ichabod801
  logging sandaab 2 471 Oct-29-2018, 03:25 AM
Last Post: sandaab
  Logging tutorial Dunatotatos 2 444 Oct-04-2018, 02:57 PM
Last Post: Dunatotatos
  Error while Logging on to outlook email account using Python inside VDI Shilton 0 522 Sep-09-2018, 06:53 AM
Last Post: Shilton
  Logging fails intermittently Nachu 1 407 Aug-28-2018, 07:42 PM
Last Post: gontajones

Forum Jump:


Users browsing this thread: 1 Guest(s)