import logging FORMAT = '%(asctime)s %(clientip)s %(user)-8s %(message)s %(haiyoushui)s' logging.basicConfig(format=FORMAT) d={'clientip':'192.168.0.1','user':'fbloggs', "haiyoushui":"12312313113213"} logger=logging.getLogger('tcpserver') logger.warning('Protocolproblem:%s','connectionreset',extra=d)