简体   繁体   English

捕获我的Go应用程序日志,使其流利

[英]Capture my Go application logs into fluentd

Currently I have a go web application containing over 50 .go files. 目前,我有一个包含50多个.go文件的Go Web应用程序。 Each file writes logs on STDOUT for now. 每个文件现在都在STDOUT上写入日志。 I want to use fluentd to capture these logs and then send them to elasticsearch/kibana. 我想使用fluentd捕获这些日志,然后将它们发送到elasticsearch / kibana。

I search on internet for solution to this. 我在互联网上搜索此问题的解决方案。 There is one package https://github.com/fluent/fluent-logger-golang . 有一个软件包https://github.com/fluent/fluent-logger-golang To use this I would need to change my whole logging related code in each go file. 要使用此功能,我需要在每个go文件中更改整个与日志记录相关的代码。 And there would be many data structures that I would need to Post to fluentd. 我将需要发布许多数据结构以使其流利。 Shortly speaking I dont want to use this approach. 简而言之,我不想使用这种方法。

Please let me know if there are any other ways to do this. 请让我知道是否还有其他方法可以做到这一点。

Thank you 谢谢

Ideally (at least in my opinion), you would essentially just pipe stdout to Fluentd. 理想情况下(至少在我看来),您实际上只是将stdout传递给Fluentd。

If you happen to be also using Docker for your application you can do this easily using the built in logging drivers: 如果您碰巧也将Docker用于您的应用程序,则可以使用内置的日志记录驱动程序轻松完成此操作:

https://docs.docker.com/engine/admin/logging/overview/ https://docs.docker.com/engine/admin/logging/overview/

Otherwise, there seem to be a few options to help get stdout to Fluentd: 否则,似乎有一些方法可以帮助您将Fludd的标准输出:

12Factor App: Capturing stdout/stderr logs with Fluentd 12Factor应用程序:使用Fluentd捕获stdout / stderr日志

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM