code: private static PrintStream unwrap(PrintStream stream) {
          try {
              Method mth = stream.getClass().getMethod("getRoot", null);
              return (PrintStream) mth.invoke(stream, null);
          } catch (Throwable t) {
              return stream;
          }
      }
docs: When working inside an OSGi framework with Felix Gogo installed,
  we need to make sure the log statements are actually printed to
  the console, not the thread based output stream (for example when
  using an SSH connections, logs are not supposed to go back to
  the ssh user...).
  This method retrieve the wrapped stream/
  Note that this method is only called if follow == false.