发现一个很快的golang logging模块

Posted Golang服务端开发之道

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了发现一个很快的golang logging模块相关的知识,希望对你有一定的参考价值。

github地址:https://github.com/uber-go/zap

 

Log a message and 10 fields:

PackageTimeObjects Allocated
技术分享图片 zap 3131 ns/op 5 allocs/op
技术分享图片 zap (sugared) 4173 ns/op 21 allocs/op
zerolog 16154 ns/op 90 allocs/op
lion 16341 ns/op 111 allocs/op
go-kit 17049 ns/op 126 allocs/op
logrus 23662 ns/op 142 allocs/op
log15 36351 ns/op 149 allocs/op
apex/log 42530 ns/op 126 allocs/op

Log a message with a logger that already has 10 fields of context:

PackageTimeObjects Allocated
技术分享图片 zap 380 ns/op 0 allocs/op
技术分享图片 zap (sugared) 564 ns/op 2 allocs/op
zerolog 321 ns/op 0 allocs/op
lion 7092 ns/op 39 allocs/op
go-kit 20226 ns/op 115 allocs/op
logrus 22312 ns/op 130 allocs/op
log15 28788 ns/op 79 allocs/op
apex/log 42063 ns/op 115 allocs/op

Log a static string, without any context or printf-style templating:

PackageTimeObjects Allocated
技术分享图片 zap 361 ns/op 0 allocs/op
技术分享图片 zap (sugared) 534 ns/op 2 allocs/op
zerolog 323 ns/op 0 allocs/op
standard library 575 ns/op 2 allocs/op
go-kit 922 ns/op 13 allocs/op
lion 1413 ns/op 10 allocs/op
logrus 2291 ns/op 27 allocs/op
apex/log 3690 ns/op 11 allocs/op
log15 5954 ns/op 26 allocs/op

以上是关于发现一个很快的golang logging模块的主要内容,如果未能解决你的问题,请参考以下文章

Golang之beego读取配置信息,输出log模块

golang配置文件热更新

Golang Package-log

python logging TimedRotatingFileHandler 模块问题排查

RPC in Golang

Python logging模块日志存储位置踩坑