logdna / rails

ActiveSupport::Logger plugin for LogDNA
MIT License
7 stars 4 forks source link

Not working with lograge #5

Open haffla opened 6 years ago

haffla commented 6 years ago

Hey guys,

there seems to be a problem with this gem in combination with the lograge gem. Whenever lograge is enabled the logger isn't sending any logs, no errors, no warnings, nothing.

This is what I am doing in config/production.rb.

config.lograge.enabled = true
config.lograge.formatter = Lograge::Formatters::Logstash.new

config.logger = Logdna::RailsLogger.new(LOG_DNA_API_KEY,
    app: "some_app",
    level: "INFO",
    env: "PRODUCTION")
jmadkins commented 6 years ago

I can confirm I was able to reproduce this issue locally. In my case, I didn't use a formatter. However, not enabling lograge started sending logs to logdna again.

jmadkins commented 5 years ago

Wish we had an update on this.

neroglu commented 5 years ago

Hey there, thank you so much for bringing this up to our attention. I am having one of our developers check this. Apologize for the delay in response.

bsbeeks commented 5 years ago

I can also confirm that logs are not being sent when lograge is enabled.

cooperluetje commented 5 years ago

I am having the same issue and found that some logs can be sent, but not the logs generated by lograge. For example I am using the 'active_model_serializers' gem and it outputs the following to logdna.

Rendered ActiveModel::Serializer::CollectionSerializer with ActiveModelSerializers::Adapter::Attributes (47.84ms)

The only log that is missing is the one liner generated by lograge. If I disable the active model serializer logging, no logs are sent.

mustmodify commented 5 years ago

@neroglu @MarcinPiekarniak any update on this?

MarcinPiekarniak commented 5 years ago

@haffla @mustmodify @cooperluetje @bsbeeks @neroglu @jmadkins

I have just checked lograge and logdna and I think https://github.com/logdna/rails/issues/7 was actually the issue because I managed to send some logs from lograge

Jul 12 16:43:41 debian-msi some_app INFO method=GET path=/ format=html controller=Rails::WelcomeController action=index status=200 duration=6.47 view=4.51 db=0.00 
Jul 12 16:43:44 debian-msi some_app INFO method=GET path=/ format=html controller=Rails::WelcomeController action=index status=200 duration=8.78 view=5.90 db=0.00 
Jul 12 16:58:02 debian-msi some_app INFO method=GET path=/ format=html controller=Rails::WelcomeController action=index status=200 duration=6.15 view=4.73 db=0.00 

Use Logdna::Ruby for now (Logdna::RailsLogger is wrapper for it that used obsolete version with bug)

  config.lograge.enabled = true
  config.logger = Logdna::Ruby.new(KEY,
    app: "some_app",
    level: "INFO",
    env: "PRODUCTION")

But it's not easy to merge loggers to log to Logdna , files (log/development.log etc) and stdout at the same time. I use standard rails logger and logdna-agent that automatically gathers info from all files.

haffla commented 5 years ago

I am not using the service anymore because I didn't get any feedback here from the staff. I even tried to fix the issue myself but the code is such a mess and so not Ruby that I gave up.