If you take a look at the pexpect.py source file, you'll see that the approach taken to logging is simply writing what is sent/received to the child process to a stream (which can be a file or, for example, sys.stdout if you prefer to log to the console). Therefore what you asked for is impossible without changing the pexpect sources, to for example, be able to use a standard library logging module logger for output (hint: maybe a good opportunity to contribute an enhancement to the project?).