Forums

Problem importing logging module

Hi,

is this concerning the "logging" module in python3.4?

When using this module in console (on python3.4), it works fine (I copy/pasted between console and script).

When creating a script, I receive the following error:

    logging.basicConfig(level=logging.DEBUG, format=' %(asctime)s -%(levelname)s - %(message)s')
AttributeError: 'module' object has no attribute 'basicConfig'

The first 3 lines of the script are:

import logging
logging.basicConfig(level=logging.DEBUG, format=' %(asctime)s - %(levelname)s- %(message)s')
logging.debug('Start of program')

or do I need to create a seperate thread for this one.

[admin] Moved from here.

That sounds like you have another module called logging somewhere on your Python system path -- perhaps one of the directories or files in your own code is called logging or logging.py?

Hi Giles

thank you for your answer. the file itself was called logging.py, since it was an exercise on logging. renamed the file and it worked.

Thanks a lot for your help!

Ah, that would explain it :-) Glad that sorted it out!