python-log

Python日志

python确实挺简单,用起来确实挺方便,但是python的日志我真想说一句头疼

只输出到文件

import logging

# 改成对应的日志路径,推荐使用绝对路径
logging.basicConfig(level=logging.INFO,
                    filename='log.log',
                    filemode='a',
                    format='%(asctime)s - %(filename)s[line:%(lineno)d] - %(levelname)s: %(message)s')
					

def main():
    #print("hello world")
	logging.info("hello world")


if __name__ == '__main__':
    main()

参考资料

[1] http://python.jobbole.com/81666/
[2] https://www.jianshu.com/p/4f6ff84cb3e9
[3] https://my.oschina.net/leejun2005/blog/126713 python 日志模块 logging 详解
[4] http://logbook.readthedocs.io/en/stable/
[5] https://github.com/getlogbook/logbook
[6] https://github.com/metachris/logzero
[7] https://www.jianshu.com/p/d615bf01e37b python logging日志模块以及多进程日志
[8] http://blog.csdn.net/liuchunming033/article/details/39080457 Python中的logging模块就这么用
[9] https://www.jianshu.com/p/72fb43127c85 Python日志教程