繁体   English   中英

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

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

我正在关注这篇Fluentd帖子,以设置Fluentd with Rails的工作版本。 我的fluent-logger.yml

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

application.rb

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

我的td-agent.conf指令如下所示:

<source>
  type forward
  port 24224
</source>

<match foo>
  type stdout
</match>

启动Rails服务器时,看不到任何日志消息通过管道传递到td-agent.log。 我正在使用act-fluent-logger-rails gem。

但是,当我在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"})

我可以看到STDOUT填充了我发送的消息。 在应用中运行该应用时,我在哪里出错? 任何对此提神醒脑! TIA。

也许您的Rails应用是一个API。 在这种情况下,您可能需要设置config.lograge.base_controller_class = 'ActionController::API'

暂无
暂无

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

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