title: Why is exception.printStackTrace() considered bad practice?
body: <p>There is a lot of <a href="http://fahdshariff.blogspot.com/2010/10/redirect-stdout-to-logger.html" rel="noreferrer">material</a> out <a href="http://checkstyle.sourceforge.net/config_regexp.html" rel="noreferrer">there</a> which suggests that printing the stack trace of an exception is bad practice.</p>
  <p>E.g. from the RegexpSingleline check in Checkstyle:</p>
  <blockquote>
  <p>This check can be used [...] to find common bad practice such as calling ex.printStacktrace()</p>
  </blockquote>
  <p>However, I'm struggling to find anywhere which gives a valid reason why since surely the stack trace is very useful in tracking down what caused the exception. Things that I am aware of:</p>
  <ol>
  <li><p>A stack trace should never be visible to end users (for user experience and security purposes)</p>
  </li>
  <li><p>Generating a stack trace is a relatively expensive process (though unlikely to be an issue in most 'exceptional' circumstances)</p>
  </li>
  <li><p>Many logging frameworks will print the stack trace for you (ours does not and no, we can't change it easily)</p>
  </li>
  <li><p>Printing the stack trace does not constitute error handling.  It should be combined with other information logging and exception handling.</p>
  </li>
  </ol>
  <p>What other reasons are there for avoiding printing a stack trace in your code?</p>