python. How to redirect Maya history?
<p>All Maya script logs and errors printed in history tab. This is output from all commands and python scripts.</p>

<p>For better debugging scripts I want all the logs were sent somewhere on the server. How to intercept and send the output to your script. Then I will do all that is necessary, and the output is either a remote console, or somewhere in the files on the server. </p>

<p>The task to intercept the output. How to do it?</p>

<p><a href="https://i.stack.imgur.com/uvjsl.jpg" rel="nofollow"><img src="https://i.stack.imgur.com/uvjsl.jpg" alt="enter image description here"></a></p>

<p>You can also redirect Script Editor history using Maya's <code>scriptEditorInfo</code> command found <a href="http://help.autodesk.com/cloudhelp/2017/ENU/Maya-Tech-Docs/CommandsPython/scriptEditorInfo.html" rel="nofollow">here</a>:</p>

<p>An example usage of this would be something like:</p>

<pre><code>import maya.cmds as cmds
outfile = r'/path/to/your/outfile.txt'

# begin output capture
cmds.scriptEditorInfo(historyFilename=outfile, writeHistory=True)

# stop output capture
cmds.scriptEditorInfo(writeHistory=False)
</code></pre>

<p>There is also <code>cmdFileOutput</code> which you can either call interactively or enable/disable via a registry entry to <code>MAYA_CMD_FILE_OUTPUT</code>, documentation <a href="http://help.autodesk.com/cloudhelp/2017/ENU/Maya-Tech-Docs/CommandsPython/cmdFileOutput.html" rel="nofollow">here</a></p>

<p>Lastly, you can augment Maya start using the <code>-log</code> flag to write the Output Window text to another location.  With this however, you do not get the Script Editor output, but could be all you desire given what it is you are trying to log.</p>

python debugging logging output maya