Redirect STDOUT and STDERR to python logger and also to jupyter notebook
问题 Important to know: I am working on jupyter notebook. I want to create a logger to which I will redirect the STDOUT and STDERR but I also want to see those outputs on the jupyter notebook output console. So far what I have implemented is: import logging import sys class StreamToLogger(object): """ Fake file-like stream object that redirects writes to a logger instance. """ def __init__(self, logger, log_level=logging.INFO): self.logger = logger self.log_level = log_level self.linebuf = '' def