title: Fetch only first N lines of a Stack Trace
body: <p>I have a Factory method that returns an object from a ID call.</p>
  
  <p>Mock code:</p>
  
  <pre><code>public static Object getById(String id) {
      Object o = CRUD.doRecovery(Class, id);
      if(o == null) {
           printLogMessage("recovery by ID returned Null: " + id);
           // would really like to show only a few lines of stack trace.
      }
      return o;
  }
  </code></pre>
  
  <p>How can I show only the first N lines of the stack trace (so I know the caller of the method) without dumping the whole stack trace on the log or having to rely on external libs?</p>