Sachin Prasad
Sachin Prasad

Reputation: 5411

Custom Log file on heroku

I'm trying to create a custom log file 'log/clockwork.log' on heroku.

In application.rb file I have added this:

ClockworkLogger = ActiveSupport::Logger.new("#{Rails.root.to_s}/log/clockwork.log")

To use this loggger in my rake I'm doing:

ClockworkLogger.info("Updating Brands #{Time.now.strftime("%Y-%m-%d %H:%M:%S")}")

Now the problem is on heroku the APP isn't able to find the clockwork log file.

I'm getting this error:

rrno::ENOENT: No such file or directory - /tmp/build_bd6cb20b87892a0f8482b4260c5c5277/log/clockwork.log

Any idea what I'm doing wrong Or do you have any better way of doing it?

Upvotes: 2

Views: 1220

Answers (1)

Musannif Zahir
Musannif Zahir

Reputation: 3029

Heroku provides you with an ephemeral filesystem - you cannot rely on persisting anything to disk (this is one of the reasons why, even to view your logs on heroku, you have to use their cmdline tools)

The recommended approach is to use a logging addon

Upvotes: 4

Related Questions