Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Logging module not working with Python3

I am having issues with the standard logging module. If I open a python2.7 shell and import logging everything works fine:

$ python
>>> import logging
>>>

But if I open a python3.4 shell and import logging I get the following error:

$ python3.4
>>> import logging
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
File "<frozen importlib._bootstrap>", line 2222, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 2164, in _find_spec
File "<frozen importlib._bootstrap>", line 1940, in find_spec
File "<frozen importlib._bootstrap>", line 1916, in _get_spec
File "<frozen importlib._bootstrap>", line 1897, in _legacy_get_spec
File "<frozen importlib._bootstrap>", line 863, in spec_from_loader
File "<frozen importlib._bootstrap>", line 904, in spec_from_file_location
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/logging-0.4.9.6-py3.4.egg/logging/__init__.py", line 618
raise NotImplementedError, 'emit must be implemented '\
                         ^
SyntaxError: invalid syntax

I have no idea what the problem is and can't seem to find anyone else who has had the same issue.

like image 925
Jonathan Avatar asked Sep 03 '15 22:09

Jonathan


People also ask

Is logging a module in Python?

Python comes with a logging module in the standard library that provides a flexible framework for emitting log messages from Python programs. This module is widely used by libraries and is the first go-to point for most developers when it comes to logging.

Does Python logging module use log4j?

The inbuilt logging module in python requires some handful of lines of code to configure log4j-like features viz - file appender, file rotation based on both time & size. For one-liner implementation of the features in your code, you can use the package autopylogger .


1 Answers

logging module is by default there in Python 3 environment .No need to import it.

like image 114
SADIQUE SHAMIM Avatar answered Oct 09 '22 19:10

SADIQUE SHAMIM