'Write log output only on stdout python

I have the following code:

import logging
log = logging.getLogger(__name__.replace('__',''))
log.setLevel(logging.DEBUG)

format = logging.Formatter("%(asctime)s:%(levelname)s:%(message)s")

streamH = logging.StreamHandler(sys.stdout)
streamH.setFormatter(format)
log.addHandler(streamH)

In this way the log capure both stdout and stderr, how can I have a .log file containing only the stdout?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source