title: Python logging - exc_info only for file handler
body: <p>I define root logger and handlers for it:</p>
  
  <pre><code>_root = logging.getLogger()
  _sh = logging.StreamHandler()
  _fh = logging.FileHandler('./error.log', delay = True)
  _root.addHandler(_sh)
  _root.addHandler(_fh)
  </code></pre>
  
  <p>And module logger instance:</p>
  
  <pre><code>_log = logging.getLogger("Main")
  # In other file
  _log = logging.getLogger("Configuration")
  </code></pre>
  
  <p>Now i call <code>_log.exception</code> in try..except block:</p>
  
  <pre><code>_log.exception("Test")
  </code></pre>
  
  <p>Now i get traceback in console and file. I try to suppress printing of exc_info with console handler, but not with file handler:</p>
  
  <pre><code>class _TraceBackFilter(logging.Filter):
      def filter(self, rec):
          rec.exc_info = None
          return True
  _sh = logging.StreamHandler()
  _sh.addFilter(_TraceBackFilter())
  _root.addHandler(_sh)
  </code></pre>
  
  <p>This works on both file and console handler, traceback is completely removed for all handlers, but i need this only for console. Is any way to suppress exc_info only for console handler, not for file handler?</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>I modify <code>_TraceBackFilter</code> class.</p>
  
  <pre><code>class _TraceBackFilter(logging.Filter):
      def filter(self, rec):
          if rec.exc_info:
              logging.getLogger(rec.name).log(rec.levelno, rec.getMessage())
              return False
          else:
              return True
  </code></pre>
  
  <p>Now its works for console handler, but in file I have doubled messages, one with and one without traceback.</p>