title: How to capture all Error messages from Python and save them in a txt file
body: <p>I would like to capture all errors that are created during the runtime or during testing(using pytest) of a Python program. So far I have managed to capture all output of pytest using a plugin for pytest which saves the output to a .txt file line by line. </p>
  
  <p>But now I would like to have all the errors created by Python in a .txt file.  As I am new to Python and also new to such capturing of program output, do you have any ideas how could I achieve something like this?</p>
  
  <p>Thanks for all the answers in advance.  </p>
  
  <p>EDIT: I am creating a plugin for PyCharm IDE, which could visualize these Errors in a certain way, that is why I need those errors saved somewhere, so I can work with them later during the visualization. If there is a better way to save them, please share it. </p>