Suppose I'm working on a python project which needs to use a third-party module such as tweepy https://github.com/tweepy/tweepy. I would like to save the logs output from this third-party module to a local file so I can check it regularly. It happens that root logger is used inside tweepy so the logs are output to console. In this case, no filehandler is yet added to the root logger, so how could I save the logs to a local file?
One way I think of is to use python run.py > ~/project/logs/test.log
to redirect all logs to the local file test.log
, but is this the best way to do it? I can already see a downside: it will save all logs not only the ones from the third-party module.