actindi / act-fluent-logger-rails

Fluent logger
MIT License
118 stars 72 forks source link

Use of flush_immediately when used as a standalone logger #35

Closed nicholashibberd closed 7 years ago

nicholashibberd commented 7 years ago

Hi,

We are using this gem as a replacement for the default Rails.logger and it works great, but we are also using it as a separate logger in the same app, one that we assign to a constant with different tags, and then log to manually.

# config/initializers/ui_flow_logger.rb

UI_FLOW_LOGGER = ActFluentLoggerRails::Logger.new ...
# app/controllers/application_controller.rb

before_filter :log_ui_flow

def log_ui_flow
  UI_FLOW_LOGGER.info({foo: 'bar'}.to_json)
end

When using it this way, i.e. outside of the rack request lifecycle, the logs do not get flushed unless we set flush_immediately to true. Is this the correct technique, or are we missing something?

quek commented 7 years ago

It is the correct technique.

nicholashibberd commented 7 years ago

Thanks, thanks are you happy for me to PR a change to the docs in case others run into the same issue?

quek commented 7 years ago

Yes, please PR. Thanks

nicholashibberd commented 7 years ago

Closing - https://github.com/actindi/act-fluent-logger-rails/pull/36

fabirydel commented 3 years ago

@quek Hi, I stumbled upon this long closed issue because I'm switching from using ActFluentLoggerRails as my replacement for the default Rails logger alone to also using it a separate logger to log with it manually. Should I expect a big performance problems in terms of the extra stress this will cause to fluentd and/or in terms of the extra bit of time that now every request will take by flushing immediately every time? For a bit of context, the app I'm using it on can run 100K requests per hour on peak hours. I'd appreciate any help you can give me, thanks.