Steven Barragán
Steven Barragán

Reputation: 1244

How to setup google cloud loggin for rails app in production

The default rails production setup seems to be overwriting stackdriver logger configuration.

The stackdriver gem documentation entails that nothing else is need in order to get it to work with ruby and rails but by default a rails app has this configuration on the production.rb. I'm setting RAILS_LOG_TO_STDOUT=true.

  config.log_formatter = ::Logger::Formatter.new

  if ENV["RAILS_LOG_TO_STDOUT"].present?
    logger           = ActiveSupport::Logger.new(STDOUT)
    logger.formatter = config.log_formatter
    config.logger    = ActiveSupport::TaggedLogging.new(logger)
  end

What's the ideal setup? Logs are not displayed if this setup is removed.

Upvotes: 3

Views: 600

Answers (1)

かいぜん
かいぜん

Reputation: 361

For the use of Ruby with Stackdriver logging see this documentation on Stackdriver Logging Client Libraries and Setting Up Cloud Logging for Ruby.

Here's also a reference documentation for the APIs Module: Google::Cloud::Logging

Upvotes: -1

Related Questions