Suggested way to log to a file?

I’m leaving mitmdump running for a long time with custom input scripts. I’d like logs (created by ctx.log.*(message)) to go to a file, where it looks like ctx.log goes to STDOUT. What’s the suggested way to achieve this?

I’m reluctant to redirect all stdout,stderr to a file, because mitmdump generates a lot of messages I’d prefer not to see in this log (e.g., clientconnect & clientdisconnect messages).



You can write your own addon to log to file. In fact mitmproxy’s logging to stdout is an addon itself: