Is there full-fledge log library similar to Java's Log4J?

agolangf · · 574 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>I played with <a href="https://github.com/sirupsen/logrus" rel="nofollow">logrus</a> and found it rather minimalist, i.e. it&#39;s missing crucial features such as rotate/zip/standardized external configuration.</p> <hr/>**评论:**<br/><br/>itachi_amaterasu: <pre><p>Your application should not be concerned about what happens to logs once they are emitted. If you follow 12 factor rules, you should just emit logs to stdout, and let another application consume those logs. That way your application does not need to know whether your logs are streamed to kafka or written to disk.</p> <p>I wrote a tool for this - <a href="https://github.com/agnivade/funnel" rel="nofollow">https://github.com/agnivade/funnel</a>. Feel free to check it out.</p></pre>mallocc: <pre><p>Writing to stdout creates a synchronization bottleneck that is unacceptable for a high throughput application. 12 factor aren’t rules, they’re guidelines and often bad ones especially at scale. </p></pre>GrandOpener: <pre><p>Be that as it may, most applications aren’t high log throughput. There are a lot of nice things about logs to stdout, and it makes an excellent default choice when no additional context is given for the application in question. </p> <p>If the application generates enough logs that stdout isn’t an option, that’s a <em>lot</em> of logs. The chances that a general purpose logging system handles that well are pretty low, unless it’s been specifically optimized for such a scenario. </p></pre>itachi_amaterasu: <pre><p>If your application has high throughput logs, there <em>will</em> have to be a bottleneck <em>somewhere</em>. Doesn&#39;t matter whether you follow 12 factor rules or not. If you are managing writing logs from within your application, then you need to manage buffering, syncing to files and all that by yourself. </p> <p>Writing to stdout just creates a clean and simple way to allow the logs to be handled by a different process. And something which you can reuse for all your applications. If one app needs to stream to kafka, whereas another needs to write to elastic search, you don&#39;t need to write different code for each of your app.</p></pre>MatthiasLuft: <pre><p>If your app&#39;s purpose is to emit high volumes of logs, something&#39;s wrong. </p></pre>0xfe: <pre><p>It is quite common for high-throughput applications to emit huge log volumes for analysis. Especially for content and ad serving systems.</p></pre>MatthiasLuft: <pre><p>&#34;Logging&#34; is the wrong tool for that.</p></pre>tetroxid: <pre><p>So the answer is no</p></pre>0xfe: <pre><p>This is fine advice for cloud-based (or even general server-side) applications. However, having a full-fledged logging library that does rotation and compression is very useful for desktop software.</p> <p>OP, Uber&#39;s new lib <a href="https://github.com/uber-go/zap" rel="nofollow">zap</a> seems like a good fit.</p></pre>Smokey_Circles: <pre><p><a href="https://github.com/op/go-logging" rel="nofollow">github/op/go-logging</a> is my favorite so far</p></pre>R2A2: <pre><p>If you want log rotation you can use <a href="https://github.com/natefinch/lumberjack" rel="nofollow">https://github.com/natefinch/lumberjack</a> around most logging packages including logrus. I used it for years, it&#39;s good.</p> <p>FWIW, now that I use kubernetes I don&#39;t have a need for log rotation or sophisticated logging config. Log collection all the way. I think the lack of log4j-type sophistication can be attributed to the general move towards container orchestration. Log collection via containers&#39; STDOUT/STDERR is so prevalent now, so all you really need is a way to &#39;switch on debug logging&#39;. Logrus offers that, and it doesn&#39;t really warrant a config file IMO.</p></pre>zsaleeba: <pre><p>Do you need more features than <a href="https://github.com/golang/glog" rel="nofollow">glog</a> has?</p></pre>Zamicol: <pre><p>Uber&#39;s posted <a href="https://github.com/uber-go/zap" rel="nofollow">zap</a>. </p></pre>FatFingerHelperBot: <pre><p>It seems that your comment contains 1 or more links that are hard to tap for mobile users. I will extend those so they&#39;re easier for our sausage fingers to click!</p> <p><a href="https://github.com/uber-go/zap" rel="nofollow">Here is link number 1</a> - Previous text &#34;zap&#34;</p> <hr/> <p><sup>Please</sup> <sup>PM</sup> <sup><a href="/u/eganwall" rel="nofollow">/u/eganwall</a></sup> <sup>with</sup> <sup>issues</sup> <sup>or</sup> <sup>feedback!</sup> <sup>|</sup> <sup><a href="https://reddit.com/message/compose/?to=FatFingerHelperBot&amp;subject=delete&amp;message=delete%20dwyhzo0" rel="nofollow">Delete</a></sup></p></pre>

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

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