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

Currently I have a go web application containing over 50 .go files. Each file writes logs on STDOUT for now. I want to use fluentd to capture these logs and then send them to elasticsearch/kibana.

I search on internet for solution to this. There is one package https://github.com/fluent/fluent-logger-golang . To use this I would need to change my whole logging related code in each go file. 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.

If you happen to be also using Docker for your application you can do this easily using the built in logging drivers:

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

Otherwise, there seem to be a few options to help get stdout to Fluentd:

12Factor App: Capturing stdout/stderr logs with Fluentd