简体   繁体   中英

Is there a way to log commands from Rails console in Heroku?

Hi I am using Heroku and Ruby on Rails. In heroku I can do

heroku run rails c -a app

Which gives me console access, and I can do administrative things like deleting records

I am working in a company setting and I would like to have a log of all commands entered in the console. So if something is wrong, we can audit the logs.

Is there a way to record what is typed in the rails console?

Rails allows you to store the console history but this won't be saved in Heroku, at least not permanently.

In Heroku, when you run heroku run rails console Heroku will create a one-off dyno which will only live as long as the console session. Rails will store the history of commands on the filesystem but once the console is exited the dyno will be cleaned up and the command history file will be deleted along with it.

Rails console is a Railtie and it has some lifecycle hooks, so you could come up with some custom way to persist commands, but there is no built-in way to do it.

是的,您现在可以使用Heroku的屏蔽私有空间, https://elements.heroku.com/addons/heroku-private-spaces

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM