Python日志

1、通过网络的方式发送日志

import logging

   logging_host = ‘127.0.0.1’
   logging_port = 8888
   logging_add_url = ‘/log/add/’
   def get_logger():
       logger = logging.getLogger()
      
       http_handler = logging.handlers.HTTPHandler(
           ‘%s:%s’ % (logging_host, logging_port),
           logging_add_url,
           method=’POST’
       )
       http_handler.setLevel(logging.ERROR)
       logger.addHandler(http_handler)
      
       return logger