I have a monstrous Java app (a client of little-known application server GNUEnterprise) and its source, which I can compile back after making some changes to it. The app uses network heavily and I need to monitor each request and response. I could use a sniffer like Wireshark, but the application works with its server over SSL, so not knowing SSL-certificate's private key any sniffed traffic is pretty useless.
What can I do to make every request and response to be logged from the application itself? I need to see all sent and received headers. I don't want to alter all code responsible for network interaction. What I want is to put a code like
Network.setDefaultLogger(myCustomLoggerInstance);
somewhere near start of the app and then in the myCustomLoggerInstance
do all the logging I need.
Also, given all network operations are made with URLConnection
s, I can get response headers with con.getHeaderFields()
and request headers with con.getRequestProperties()
. But why cookies aren't there? How to dump sent and received cookies in the same way?
EDIT: What I'm trying to reach is to mimic RPC-application's communication with it's server over SSL, say, using curl
. For this I need to get detailed log of app's network traffic.
A quick way to log all SSL traffic is to startup java with:
-Djavax.net.debug=all
Or set it as a system property:
System.setProperty("javax.net.debug","all");
Brace yourself. Standard out gets NOISY if you do this!
(*Note: only logs SSL traffic and SSL debug info (handshakes, etc). Regular sockets are not logged.)