How to output errors to a file?[solved]

Hello, I´m curious about how can I output the errors(if this is really possible) I receive in my ubuntu terminal when I do bad coding in python+panda3d to a file.

Knowing this could be very usefull, as it would enable future game players to help me in fixing game errors which may come, by just sending me this file with the errors.

Thanks in advance for any help, hope this isn´t a stupid question.

Look for the section Log Messages in the manual.

Nice tip, I looked there and used the code below:

#Notify problems to file
nout = MultiplexStream()
Notify.ptr().setOstreamPtr(nout, 0)
nout.addFile(Filename(MYDIR + "/../../bug.log"))

But all I got in the file were shader errors, how I should proceed for the bug.log receive info like this(which appear in terminal also):

DirectStart: Starting the game.
Known pipe types:
  glxGraphicsPipe
(all display modules loaded.)
Traceback (most recent call last):
  File "main.py", line 10, in <module>
    g = GraphicsManager()
  File "/home/felipe/Questverse/data/code/graphics.py", line 68, in __init__
    xbase.disableMouse()
NameError: global name 'xbase' is not defined

Thanks for the help

import sys
pylog = open('path/to/pythonBug.log','w')
sys.stderr = pylog

I see, so I open(create) a new file(or overwrite previous one) and write on it(w), then I direct system(sys) stderr(which handles interpreter/terminal error output) to this file open for writting.

Thanks a lot all for your help!