title: Capture javax.net.debug to file
body: <p>I need to save the javax.net.debug=all output that is created to a file. I'm using log4j and I tried creating a logging proxy as in the code example below; however, it is not picking up the info. I am not sure where the javax.net.debug is being printed to. I tried capturing system.out and system.err this way but neither worked. Thanks for your help.</p>
  
  <pre><code>public class StdOutErrLog {
  
      private static final Logger logger = Logger.getLogger(StdOutErrLog.class);
  
      public static void tieSystemOutAndErrToLog() {
          System.setOut(createLoggingProxy(System.out));
          System.setErr(createLoggingProxy(System.err));
      }
  
      public static PrintStream createLoggingProxy(final PrintStream realPrintStream) {
          return new PrintStream(realPrintStream) {
              public void print(final String string) {
                  realPrintStream.print(string);
                  logger.info(string);
              }
          };
      }
  }
  </code></pre>