<p>Who has experience with wiring Ueber's zap logging package to Graylog? Would you share any insights? I found several open source packages to connect zap to a GELF host. Do you have any experience with one? Which one would you recommend? Any comments are welcome! </p>
<hr/>**评论:**<br/><br/>014a: <pre><p>Generally you shouldn't be worrying about where logs go from the context of your application. Its one of the <a href="https://12factor.net/logs" rel="nofollow">12 Factor guidelines</a>. </p>
<p>Dump your logs in JSON to stdout, then have a Graylog sink running in the environment. </p>
<p>Of course this doesn't work for every deployment topology, so your mileage may vary. But if your deployment topology doesn't support it, treat that as a signal that maybe something there needs improvement at some point. </p></pre>drvd: <pre><blockquote>
<p>Of course this doesn't work for every deployment topology</p>
</blockquote>
<p>Yes. That is the whole reason I need to connect zap to GELF. If I <em>could</em> I'd just log to stdout but I cannot. And yes, it would be nice if the available infrastructure would be 12 Factor compliant, but it is not and it cannot be changed and that's why I asked about experience with connecting zap to Graylog. </p></pre>014a: <pre><p>In that case, look into creating a new <a href="https://godoc.org/go.uber.org/zap/zapcore#WriteSyncer" rel="nofollow">zapcore.WriteSyncer</a> that supports GrayLog. Depending on which Graylog library you're using, you might need to write your own abstraction type to abide by an io.Writer, but once you have that it should be pretty straightfoward; create the WriteSyncer, use it to create a new zapcore.Core with an appropriate message encoder (likely just JSON), then pass that to zap.New.</p></pre>drvd: <pre><p>Thanks. The idea was less to write our own than to use an existing one. Does anybody have experience with and <em>existing</em> integration?</p></pre>
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码`
- 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传