title: Log any method call of an instance
body: <p>Is it possible to log any method call of a class instance? I have the following instance:</p>
  
  <pre><code>InputStream serverInputStream = this.serverProcess.getInputStream();
  </code></pre>
  
  <p>I would like to see at a given time during runtime what method has been called in <code>serverInputStream</code>. I believe the solution for that is reflection, specifically a proxy. I already tried to make <a href="http://www.baeldung.com/java-dynamic-proxies" rel="nofollow noreferrer">this example</a> work, but yet unable to make it running.</p>
  
  <p>I thought of a code similar to this:</p>
  
  <pre><code>MyInterceptor myInterceptor = new MyInterceptor(this.serverProcess.getInputStream());
  InputStream serverInputStream = myInterceptor.getInterceptedInstance();
  
  serverInputStream.methodOne();
  serverInputStream.methodTwo();
  serverInputStream.methodThree();
  
  myInterceptor.printIntercepts();
  </code></pre>
  
  <p>Having a result similar to this:</p>
  
  <pre><code>1. InputStream.InputStream();
  2. InputStream.methodOne();
  3. InputStream.methodTwo();
  4. InputStream.methodThree();
  </code></pre>
  
  <p>Is that possible?</p>