【python输出json日志】教程文章相关的互联网学习教程文章

python输出json日志【代码】

python 日志包 loggus 可以非常轻易的输出 json 日志,安装 pip install loggus使用可以结合具体的fields进行细例化的分割import loggusif__name__ == ‘__main__‘:loggus.SetFormatter(loggus.JsonFormatter)loggus.info("hello world")loggus.WithFields({"name": "cza","age": 18,}).info("hello world")输出日志为:{"time": "2020-11-05 18:42:03.148269", "level": "info", "msg": "hello world"}{"name": "cza", "age": 18...