shadabahmed / logstasher

Awesome rails logs
MIT License
821 stars 136 forks source link

Logstasher is not Logging Errors #79

Closed msdundar closed 5 years ago

msdundar commented 9 years ago

Hi,

I'm running a rails 4 application in development mode.

Here is my config/environments/development.rb =>

  # Logstasher Config
  # Enable the logstasher logs for the current environment
  config.logstasher.enabled = true

  # This line is optional if you do not want to suppress app logs in your <environment>.log
  config.logstasher.suppress_app_log = false

  # This line is optional, it allows you to set a custom value for the @source field of the log event
  config.logstasher.source = 'foobar'

  # This line is optional if you do not want to log the backtrace of exceptions
  config.logstasher.backtrace = false

  # This line is optional, defaults to log/logstasher_<environment>.log
  config.logstasher.logger_path = 'log/logstasher.log'

The problem is, when an application error occurs (like 404 not found) I can see the error in log/development.log but not in log/logstasher.log

How can I solve this issue?

sfate commented 9 years ago

Seems problem occurs for any log_level.. As you can see here: https://github.com/shadabahmed/logstasher/blob/master/lib/logstasher/railtie.rb#L7 Logstasher initialized as instance of ActiveSupport::OrderedOptions:

config.logstasher = ActiveSupport::OrderedOptions.new

But in new rails it also inherit an ActiveSupport default logger, which sending output to stdout.

And after that.. we moving to setup method.. where we have already defined logger:

self.logger = app.config.logstasher.logger || new_logger(self.logger_path)

And now at any call of logger output sends to default ActiveSupport::OrderedOptions logger..

This can be monkeypatched as follow:

# add this info your development.rb or other environment file
config.to_prepare do
  LogStasher.logger = Logger.new("#{Rails.root}/log/logstash_#{Rails.env}.log")
end
hut8 commented 9 years ago

+1 for this issue -- even with the monkey patch, I can't get my development Rails.logger.info to display anything in the logstash log.

astutejoe commented 8 years ago

Same here... Even with the ninja Monkey Patch, no logger calls is logged

MarcGrimme commented 8 years ago

You might want to check #108 . There is still one open topic but for me it's minor and should be fixed in another subsequent PR. Comments welcome.

MarcGrimme commented 8 years ago

Other then this I'd say get it merged soon as this is really a pain.