python logging如何不输出log到terminal而只输出到ui?
用Logging模块想把log信息输出到一个Qt ui,但是不想在terminal也同时输出了log信息。谢谢! python logging PyQt
[解决办法]
可否通过网络接收log信息,然后输出到UI上?
http://docs.python.org/2/howto/logging-cookbook.html#sending-and-receiving-logging-events-across-a-network
或者自己编写一个handler,然后addHandler()
http://docs.python.org/2/howto/logging.html#useful-handlers
[解决办法]
logging默认并不输出到显示终端,你应该用了addHandler
把这个addHandler指向GUI的控件
[解决办法]
logging.basicConfig(level=logging.INFO,
format='%(asctime)s %(filename)s[line:%(lineno)d] %(levelname)s : %(message)s',
datefmt='%Y-%m-%d %X', filename='log.log')
if 条件:
console = logging.StreamHandler()
console.setLevel(logging.INFO)
formatter = logging.Formatter('%(name)s : %(levelname)s : %(message)s')
console.setFormatter(formatter)
logging.getLogger('').addHandler(console)