How to output logging.info and logging.debug to the console?

I can only see warnings and errors, how can I get information and debug the printout? To clarify, I'm starting a tornado application with python app.py I want the information and debug logs to be printed to the console after the application starts.

 class MainHandler(tornado.web.RequestHandler): def get(self): self.write('hello fun fun test world from tornado super') logging.info('info') logging.warning('warning') logging.error('error') logging.debug('debug') application = tornado.web.Application([(r"/", MainHandler)], debug=True) 
+7
source share
3 answers

You probably need to change the level of the logging module to display debugging and informational messages in the console.

 logger.setLevel(logging.DEBUG) # this should allow all messages to be displayed 

If you do not want to display debug messages, follow these steps:

 logger.setLevel(logging.INFO) 

And just a quick few. The levels below are in order, so if you install one of them, it will display all messages of types below the set level and there will be no messages above the set level.

 logging.DEBUG logging.INFO logging.WARNING logging.ERROR logging.CRITICAL 
+8
source

By calling tornado.options.parse_command_line , you register tornado command line flags.

You can use the logging command line flag to change the logging level from the command line.

For more information: fooobar.com/questions/958665 / ...

+2
source

Here's the trick: you can directly change the internal tornados access registrar:

 import logging import tornado import tornado.log tornado.log.access_log.setLevel(logging.DEBUG) 
0
source

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


All Articles