What do you use for logging?

agolangf · · 580 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>Apologies for the possibly newbie question. Being unfamiliar with Go and the ecosystem, what are the major logging libraries people tend to use these days? </p> <hr/>**评论:**<br/><br/>nesigma: <pre><p>My recommendation is to start with the standard library log package which will probably prove sufficient for the majority of your needs. </p> <p>If and only if, you discover that there&#39;s something you really need from a 3rd party logging library that you cannot possibly achieve with the standard log package (combined with some programming), then go ahead and use that 3rd party library.</p></pre>thesnowmancometh: <pre><p>Big love for <a href="https://github.com/Sirupsen/logrus">https://github.com/Sirupsen/logrus</a> I&#39;ve seen a ton of production tools that use logrus, too.</p></pre>cryp7ix: <pre><p>Although I still use Logrus myself, <a href="http://engineering.dailymotion.com/our-way-to-go/">Our way to Go by dailymotion</a> and <a href="http://dave.cheney.net/feed">Let’s talk about logging by Dave Cheney</a> really pushed me away from leveled logs.</p></pre>wakaflockafliz: <pre><p>That &#34;Let&#39;s talk about logging by Dave Cheney&#34; link seems broken.</p> <p>In hopes of helping others access this info, here is a working link:</p> <p><a href="http://dave.cheney.net/2015/11/05/lets-talk-about-logging" rel="nofollow">http://dave.cheney.net/2015/11/05/lets-talk-about-logging</a></p></pre>cryp7ix: <pre><p>ouch, thanks! (I noticed I didn&#39;t have Dave&#39;s blog in my feed system while pasting the links together.. X11 pastafail)</p></pre>Growlizing: <pre><p>Would also like to recommend <a href="http://engineering.dailymotion.com/our-way-to-go/" rel="nofollow">Our way to Go</a>.</p></pre>_taijitu_: <pre><p>A chainsaw.</p> <p>... I&#39;ll show myself out.</p></pre>anacrolix: <pre><p>A++</p></pre>cypriss9: <pre><p>Once you get beyond basic logs and you want to instrument your production app to record telemetry, my recommendation is to use <a href="https://github.com/gocraft/health" rel="nofollow">https://github.com/gocraft/health</a></p> <p>It lets you instrument your app and then plug in backend &#39;sinks&#39; that send logs to your choice of files, syslog, statsd, bugsnag, etc.</p></pre>mdmd136: <pre><p><a href="https://github.com/golang/glog" rel="nofollow">https://github.com/golang/glog</a></p></pre>pusic007: <pre><p><a href="https://github.com/ivpusic/golog" rel="nofollow">https://github.com/ivpusic/golog</a></p></pre>wakaflockafliz: <pre><p>I have been using <a href="https://github.com/op/go-logging" rel="nofollow">https://github.com/op/go-logging</a> for years now and while not perfect, I feel it meets my needs nicely.</p></pre>RandNho: <pre><p>Standard logger and <a href="https://github.com/natefinch/lumberjack/tree/v2.0" rel="nofollow">https://github.com/natefinch/lumberjack/tree/v2.0</a> for rotation, when I need rotation.</p></pre>vruin: <pre><p>As <a href="/u/thesnowmancometh" rel="nofollow">/u/thesnowmancometh</a> mentions, <a href="https://github.com/Sirupsen/logrus" rel="nofollow">logrus</a> is the most popular if you are into levels. But <a href="/u/nesigma" rel="nofollow">/u/nesigma</a> is right in that you should not bring dependencies until you know what you need from them, stick to the standard library logger until it&#39;s not enough. Lots of folks I&#39;ve spoken to just write their own lib around the standard library with just what they need.</p> <p>I myself wrote one <a href="https://github.com/comail/colog" rel="nofollow">https://github.com/comail/colog</a> that I configure &#34;under&#34; the stdlib, so I only use the normar logger everywhere in my code and enable/disable that extra features layer as I see fit with a single line of code.</p></pre>

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

580 次点击  
加入收藏 微博
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传