简体   繁体   English

Fluentd:无法将Rails日志传送到Fluentd STDOUT

[英]Fluentd: Not able to pipe Rails log to Fluentd STDOUT

I'm following this Fluentd post to setup a working version of Fluentd with Rails. 我正在关注这篇Fluentd帖子,以设置Fluentd with Rails的工作版本。 My fluent-logger.yml : 我的fluent-logger.yml

development:
  fluent_host: "localhost"
  fluent_port: 24224
  tag: "foo"
  messages_type: "string"

The application.rb : application.rb

config.log_level = :info
config.logger = ActFluentLoggerRails::Logger.new
config.lograge.enabled = true
config.lograge.formatter = Lograge::Formatters::Json.new

My td-agent.conf directives looks like this: 我的td-agent.conf指令如下所示:

<source>
  type forward
  port 24224
</source>

<match foo>
  type stdout
</match>

When I start my rails server, I do not see any log messages getting piped to td-agent.log . 启动Rails服务器时,看不到任何日志消息通过管道传递到td-agent.log。 I'm using the act-fluent-logger-rails gem. 我正在使用act-fluent-logger-rails gem。

However, when I use the fluent-logger gem in the rails console and execute these commands: 但是,当我在rails控制台中使用fluent-logger gem并执行以下命令时:

require 'fluent-logger'
Fluent::Logger::FluentLogger.open(nil, :host=>'localhost',:port=>24224)
Fluent::Logger.post("fluentd.test.follow",{"from"=>"A","to"=>"B"})

I'm able to see the STDOUT getting populated with the message I sent. 我可以看到STDOUT填充了我发送的消息。 Where am I going wrong here, with running it in the app? 在应用中运行该应用时,我在哪里出错? Any heads up on this would be great! 任何对此提神醒脑! TIA. TIA。

Perhaps your Rails app was an API. 也许您的Rails应用是一个API。 In that case you may have to set config.lograge.base_controller_class = 'ActionController::API' . 在这种情况下,您可能需要设置config.lograge.base_controller_class = 'ActionController::API'

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

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