How To Implement logRequestResponse in Spray

Spray has the feature to log request and response of every route through logRequestResponse. We needn’t to add log in each route because it could be done from a single place. This also helps to maintain clean code.
Please see below example:-

Now execute sbt run, run the http://localhost:8080/module/BANG from browser and see the log in console.

We could change log format and level, depending on the requirement. For complete example, you can pull the code from spray-akka-starter.

Written by 

Ayush is the Sr. Software Consultant @ Knoldus Software LLP. In his 5 years of experience he has become developer with proven experience in architecting and developing web applications. Ayush has a Masters in Computer Application from U.P. Technical University, Ayush is a strong-willed and self-motivated professional who takes deep care in adhering to quality norms within projects. He is capable of managing challenging projects with remarkable deadline sensitivity without compromising code quality. .

3 thoughts on “How To Implement logRequestResponse in Spray

Leave a Reply

%d bloggers like this: