lograge
lograge copied to clipboard
Question: How to filter just 200 OK for a given action
I have an endpoint /health for health checks. That action receives a lot of requests that are pretty useless in the logs.
Now I see that I can use
config.lograge.ignore_actions` = ['PagesController#health']
In that case, an exception would be logged? Because I would like to just filter the 200 OK, but not the errors.
- Ideally I would like to log any status different from 200 OK. Is it possible?
- If the above is not possible (e.g. any
INFO [500]would be omitted), is it at least possible to log the exception itself raised by that action?
Thank you very much
I'm looking to enact a similar process, did you find a solution?
You can use something like this:
config.lograge.ignore_custom = lambda do |e|
# return true here if you want to ignore based on the event
return true if e.payload[:status].try(:to_i).try(:<, 400) # ignore HTTP 1xx, 2xx, 3xx
return false
end