Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to have http wire logging in Play 2

I want to log each HTTP request and response (for debugging/development) within play 2 (2.0 for now, but I'am willing to switch to 2.X once available; Preferred language is Scala).

I found I can use onRouteRequest to get hold of the requestHeader, but this misses the body.

ActionComposition may be an alternative, but this also does not seem to be the plain request.

Getting hold of the HTTP Response seems to be even more complicated. Obviously it would be nice to customize/truncate logging based on the content-type to avoid logging of image/binary data.

Response Logging should also work with Async Results.

like image 662
eigenbrodtm Avatar asked Nov 04 '22 09:11

eigenbrodtm


1 Answers

You could make use of filters (a new feature introduced in Play 2.1). Check out http://www.playframework.com/documentation/2.1.1/ScalaHttpFilters at "More powerful filters"

like image 125
Manuel Bernhardt Avatar answered Nov 08 '22 10:11

Manuel Bernhardt