2

So there a couple of similar questions regarding this but I've tried all of the answers and still can not get my app to do simple logging.

I'm using Rails 4.2, Ruby 2.2, Puma on a Heroku free account; So far I've tried:

  1. Adding config.logger = Logger.new(STDOUT), config.log_level = :debug, and config.logger.level = Logger::DEBUG to my production.rb file as specified here, here and here
  2. Adding the rails_12factor gem as specified by Heroku here
  3. Added ActiveRecord::Base.logger.level = Logger::DEBUG to my environment.rb file as outlined here
  4. Added $stdout.sync = true to my config.ru file as outlined here

In my app I have the following (none of which I can see in production when using $ heroku logs --tail nor in papertrail)

Rails::logger.debug "Test of 'Rails::logger.debug' logging"
Rails.logger.debug "Test of 'Rails.logger.debug' logging"
puts "Test of 'puts' logging"
Community
  • 1
  • 1
Eric Norcross
  • 4,177
  • 4
  • 28
  • 53

2 Answers2

0

So the problem was actually that I accidently had two classes with the same name; Apparently ruby doesn't doesn't throw an error in that event and because config.eager_load is set to false in dev, it always worked. The app always ended up loading the class without logging in production first which is why I never saw any messages.

Eric Norcross
  • 4,177
  • 4
  • 28
  • 53
-2

If you're on a local environment. This worked for me.

Create a Heroku account. Install Heroku Toolbelt.

From your terminal run heroku login, youll be be prompted qith your username and password, enter your credentials. In Gemfile, add the pg gem to your Rails project. Change:

gem sqlite to

gem 'sqlite3', group: :development gem 'pg', '0.18.1', group: :production In Gemfile, add the rails_12factor gem::

gem 'rails_12factor', group: :production In the terminal, install the gems specified in the Gemfile:

$ bundle install Ensure config/database.yml is using the postgresql adapter. Change:

production: <<: *default database: db/production.sqlite3 to

production: <<: *default adapter: postgresql database: db/production.sqlite3 Commit your changes to git:

$ git add . $ git commit -m "Heroku config" In the terminal, create an app on Heroku:

$ heroku create Push your code to Heroku:

$ git push heroku master If you are using the database in your application, migrate the database by running:

$ heroku run rake db:migrate

It has worked well for me. I am on windows.