How to duplicate sys.stdout to a log file?

前端 未结 17 1264
醉酒成梦
醉酒成梦 2020-11-22 06:54

Edit: Since it appears that there\'s either no solution, or I\'m doing something so non-standard that nobody knows - I\'ll revise my question to also ask: What is the best w

17条回答
  •  庸人自扰
    2020-11-22 07:40

    What you really want is logging module from standard library. Create a logger and attach two handlers, one would be writing to a file and the other to stdout or stderr.

    See Logging to multiple destinations for details

提交回复
热议问题