golang开发:类库篇(一) Zap高性能日志类库的使用 (2)

执行下,就会在日志文件上输入按照我们配置日志格式。

tail -f /tmp/zap.log {"level":"debug","t":"20190630_044053","caller":"myproject/main.go:21","msg":"output","app":"test","detail":["[test hello world]"]}

然后我们试下控制台输出,修改三个console相关的配置代码
···
OutputPaths: []string{"stdout"},
ErrorOutputPaths: []string{"stdout"},
控制台窗口就会输出
{"level":"debug","t":"20190630_092533","caller":"myproject/main.go:21","msg":"output","app":"test","detail":["[test hello world]"]}
···

当然了,zap最想的使用和文档,看官网嘛
https://github.com/uber-go/zap
https://godoc.org/go.uber.org/zap

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/zygysw.html