简体   繁体   中英

How to see verbose error logs in the Rails console when running in production?

One of the biggest challenges I have with my Ruby on Rails application is that troubleshooting production bugs can become extremely painful due to the lack of information in the logs.

I, [2021-01-08T14:42:44.834966 #223]  INFO -- : [1b0730a0-21e4-476f-92a6-6b4d86e98010] undefined method `id' for nil:NilClass
I, [2021-01-08T14:42:44.865441 #223]  INFO -- : [1b0730a0-21e4-476f-92a6-6b4d86e98010] No template found for SubscriptionPaymentController#payment_webhook, rendering head :no_content
I, [2021-01-08T14:42:44.865759 #223]  INFO -- : [1b0730a0-21e4-476f-92a6-6b4d86e98010] Completed 204 No Content in 887ms (ActiveRecord: 7.3ms)

For example, the above code shows an error in production, but there's no verbose information on how to fix it. In dev, I believe it would show the specific line number of the code where the error occurred.

Since this production.log file can't be shown to the user in the UI anywhere, is there any way I could just simply turn on "more" verbose logging so that I can easier figure out where bugs occur in production?

In your production.rb file you can change config.log_level property to debug , like this config.log_level =:debug . This is the lowest level available. ( more info on log levels )

HOWEVER this is only recommended to be done in production when you are trying to fix something, but then it should be reverted to a higher level otherwise you risk filling the disk space very fast.

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