On Thu, Aug 16, 2018 at 1:04 AM, belgoros <
s.ca...@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!