简体   繁体   中英

How do I log responses from my Rails Controllers?

I have a Rails API which is currently used by a mobile app to perform database transactions.

The API returns an JSON object and I'd like to be able to log all the responses that each mobile app request returns on my Rails Server.

I've looked at lograge but they doesn't seem to have the ability to log responses from ActionController.

How can I approach this?

You can log your responses right before sending them to your mobile application. See chapter 2.3

You will have something like

def your_method
  #do_something
  logger.info response_params
  respond_with response_params
end

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