我正在关注这篇Fluentd 帖子,以使用 Rails 设置 Fluentd 的工作版本。我的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。