On Thu, Aug 16, 2018 at 1:04 AM, belgoros <s.cambour@gmail.com> wrote:
> Yeas, I knew that. I tried both tcp and udp, none of them worked. The only
> one that works is when I specify the type as file:
>
> config.lograge.logger = LogStashLogger.new(type: :file, path:
> 'log/development.log', sync: true)
Taking "lograge" out of the picture for the moment, using this config:
config.logger = LogStashLogger.new(type: :udp, host: '127.0.0.1',
port: 5228, verify_hostname: false)
> This way the logs shall be written in Logstash format in development.log.
> The question I have not found the answer to is what host and port values
> should correspond to ? Are they the values of Logstash server ?
I do this below in a Rails console:
Loading development environment (Rails 5.2.1)
2.5.1 (main):0 > Rails.logger.info("test message from a rails app")
=> true
2.5.1 (main):0 > Rails.logger.flush()
=> true
2.5.1 (main):0 >
with this test endpoint (Erlang, but that's not important)
Eshell V9.2 (abort with ^G)
1> {ok, Logstash} = gen_udp:open(5228, [binary, {active,false}]).
{ok,#Port<0.490>}
2> gen_udp:recv(Logstash, 0).
{ok,{{127,0,0,1},
49369,
<<"{\"message\":\"test message from a rails
app\",\"@timestamp\":\"2018-08-16T13:25:48.113-07:00\",\"@versio"...>>}}
3>
Note that nothing showed up on receiving end until I flushed the logger
on the Rails side, so that might have something to do with your testing
not apparently doing anything. But for sure, the `host` and `port` values
are for the remote logstash endpoint.
HTH!
--
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com
twitter: @hassan
Consulting Availability : Silicon Valley or remote
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CACmC4yAY6ncMEniFiyFPdFsoOMcNu3oZ3jz5%2BNhOf5DEcSRa_g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment