1
votes

So I have the following scenario (it's a Grails 2.1 app):

  • I have a Controller that can be accessed via //localhost:8080/myController
  • This controller in turn executes a call to another URL opening a connection using new URL("https://my.other.url").openConnection()
  • I want to capture the request so I can log the information

I have a Filter present in my web.xml already which does the job well for controllers mapped in my app. But as soon as a request is fired to an external URL, I don't get anything.

I understand that my filter will only be invoked to URLs inside my app, and that depends on my filter mapping which is fine.

I'm struggling to see how a solution inside the app is actually viable. I'm thinking of using a mixed approach with the DevOps team to capture such outgoing calls from the container and then log them into a separate file.

I guess my questions are:

  1. Is there a way to do it inside the app itself?
  2. Is the approach I'm planning a sensible one?

Cheers!

1

1 Answers

0
votes

Any reason why you don't want to use http-builder? There a Grails plugin for it, and it makes remote XML calls much easier than handling the plumbing yourself. At the bottom of the linked page they describe how you can enable request logging via log4j configuration.