How to write the output of Blender console out to a file
On Linux/Ubuntu its ./blender &gt; myLog123.txt from the working directory.  

./blender &amp;&gt; myLog123.txt to include Stderr.

In Python you can do

import sys
file = open(filepath, "w")
sys.stdout = file
#...
#...
sys.stdout = sys.__stdout__ #reset
file.close()


to catch the console output while your script is running.