error creating daily logs in rails app on heroku

50 views Asked by At

I have a rails 5 app that I'd like to push to heroku, in which I have a logger that creates a daily log file, which I use to print out various pieces of status information. This works in development, but I get an error when I try to push it to heroku (after pushing everything to git).

The error I receive: "Errno::ENOENT: No such file or directory @ rb_sysopen - /tmp/build_e3fe50d2e37e0a51f1bc7d94dd1fc2f3/log/daily_logs_production/2016-12-19.log "

Here is the relevant portion from production.rb:

if ENV["RAILS_LOG_TO_STDOUT"].present?
    logger           = ActiveSupport::Logger.new("#{Rails.root}/log/daily_logs_production/#{Time.now.strftime('%Y-%m-%d')}.log", 'daily')
    logger.formatter = config.log_formatter
    config.logger = ActiveSupport::TaggedLogging.new(logger)
  end

Any idea what is wrong? Thank you!

1

There are 1 answers

0
phoet On BEST ANSWER

whether or not you are getting an error can be neglected.

due to the ephemeral filesystem of heroku dynos you should not use it for such purposes.

install a plugin of the Logging category instead.