python - log the same thing in two files twisted
问题 I'd like to know if there's a way to log the same thing in two files in twisted. Let's say this is the code, now I'd like the same output going to "logs.log" to be redirected to sys.stdout . if __name__ == "__main__": log.startLogging(open("logs.log", 'a')) log.startLogging(sys.stdout) 回答1: This is absolutely possible and easier than ever before if you're on the latest version of Twisted. from sys import stdout from twisted.logger import Logger, textFileLogObserver, globalLogBeginner # start