I had to allow some of our admin users to view the logic and results of a parsing module to help find and pinpoint improvements. Since my backend Python Celery module already uses Python logging, I needed a way to log to a string to display the results on a Web page.
Here’s a function that will return a StringIO variable and a Python logger. Once you are done logging or need the logger results, you can easily get the output logger in a string. Also, I found a Stack Overflow article to remove Django database debug info from being logged so I added this as a default parameter that can be changed.
Here’s the Gist: