roidrage / lograge

An attempt to tame Rails' default policy to log everything.
http://www.paperplanes.de/2012/3/14/on-notifications-logsubscribers-and-bringing-sanity-to-rails-logging.html
MIT License
3.46k stars 300 forks source link

No logs shown in CloudWatch when lograge is enabled (Rails/ECS/Fargate) #325

Open philipjkim opened 3 years ago

philipjkim commented 3 years ago

I see no logs in CloudWatch after enabling lograge on my Rails app. When I disable lograge, logs are shown in CloudWatch. I don't know the root cause. (AWS ECS with Fargate)

No problem when I run the Rails app on localhost. (all logs shown in STDOUT & log file not created)

Here's the codes related to logging:

config/environments/development.rb:

  config.log_formatter = ::Logger::Formatter.new
  logger = ActiveSupport::Logger.new(STDOUT)
  logger.formatter = config.log_formatter
  config.logger = logger

  config.after_initialize do
    HttpLog.configure do |config|
      config.logger = Rails.logger
    end
  end

config/initializers/lograge.rb:

Rails.application.configure do
  # I can see CloudWatch logs if I comment out the following 2 lines.
  config.lograge.enabled = true
  config.lograge.ignore_actions = ['MiscController#ping']
end

More info:

stevenpitts commented 1 year ago

I've also experienced this, but in my case all the logs showed up in a group after ~1 hour of the app running, possibly after some number of log lines were queued up. Might be the case here too?