Description: StreamHandler
Keywords: lib

### 6.28.2.1 StreamHandler

The `StreamHandler` class sends logging output to streams such as sys.stdout, sys.stderr or any file-like object (or, more precisely, any object which supports `write()` and `flush()` methods).

class `StreamHandler`( | [strm])

  Returns a new instance of the `StreamHandler` class. If strm is specified, the instance will use it for logging output; otherwise, sys.stderr will be used.

`emit`( | record)

  If a formatter is specified, it is used to format the record. The record is then written to the stream with a trailing newline. If exception information is present, it is formatted using `traceback.print_exception()` and appended to the stream.

`flush`( | )

  Flushes the stream by calling its `flush()` method. Note that the `close()` method is inherited from `Handler` and so does nothing, so an explicit `flush()` call may be needed at times.