fedest
fedest

Reputation: 1366

Rails Have a custom Logger in Heroku

I need to have a custom Logger that logs specific actions that occur in my deployed application in Heroku. This log is for the user to view (that's why the default logger is no good here).

While testing on development on local everything is fine. I have

logger = Logger.new(PATH)
logger.info("...")

PATH is set on environment variables.

Now I want to deploy to Heroku but I find myself with a problem: how can the user view this log? Where would I need to save it?

Upvotes: 0

Views: 209

Answers (2)

oreoluwa
oreoluwa

Reputation: 5633

Heroku has an ephemeral filesystem meaning whatever file you upload would be deleted shortly afterwards. If you need a custom logger on Heroku, I'd say you should probably use something that is more persistent. You may use something like Redis.

Look at this answer for more info.

Upvotes: 0

Vasfed
Vasfed

Reputation: 18504

On heroku filesystem is read-only, you should log to stdout. Default log can be directed there by rails_12factor gem (or configure by youself, but the former is easier)

But for custom log, that is going to be viewed by the user it's better to write to db, because probability of future access control being needed is high

Upvotes: 1

Related Questions