[英]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.