PyDev Console does not print logs for all levels

I have average experience with python, btw I just installed eclipse and pydev on top of it. And it’s strange that the behavior of the registration module looks strange.

import datetime import logging print datetime.date.today() print logging logging.info("test") print logging.info("test2") -------- OUTPUT:: -------- 2012-10-25 <module 'logging' from '/usr/lib/python2.7/logging/__init__.pyc'> None 

Any clue why logging.info is not working?

btw is not sure if this is related, but immediately after installing pydev, import registration itself did not work. Then I checked the configuration of the python interpreter, and the registration module was not there in the list of forced built-in functions (Windows-> preference-> Pydev-> Interpreter (python) β†’ Forced Builtins). So I added that manually for import logging. Thanks in advance for any pointers.

+4
source share
3 answers

Since the default log level is WARNING and logging.info() are logged at a level below this. See explanation here and docs .

To do what you want, you can try the following:

 logger = logging.getLogger('name_of_your_logger') logger.setLevel(logging.INFO) logger.info("Should get logged") 
+3
source

you can change the default level using setLevel to the first logging statement.

 logging.getLogger().setLevel(logging.DEBUG) 
0
source

Try this if you want to write to stdout:

 import sys import logging logger = logging.getLogger() handler = logging.StreamHandler(sys.stdout) handler.setLevel(logging.DEBUG) logger.addHandler(handler) logger.setLevel(logging.DEBUG) logger.info('teste') 

Output:

Teste

0
source

Source: https://habr.com/ru/post/1441916/


All Articles