This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author janis.slapins
Recipients janis.slapins, vinay.sajip
Date 2016-04-01.19:47:31
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1459540051.67.0.836733968292.issue26606@psf.upfronthosting.co.za>
In-reply-to
Content
Many examples in the internet only show the usage of the filename parameter of basicConfig() and almost no one shows how to use the stream. That's why I wanted to use the filename parameter. But now I tested other options and they work for me. My case may be very specific as I need to log words in very different languages including not only those having the Latin script but also cyrillic - Russian, Greek etc.

Regarding the codecs module and open() - yes, I made a mistake. There is no need for that in Python3.

About sys.stdout. I understand the redirection in the following way (also shown in the Dive Into Python book):
normal_stdout = sys.stdout
sys.stdout = open(mylogfile, 'w', encoding='utf-8')
logging.basicConfig(level=logging.INFO, stream=sys.stdout)

After that, all the STDOUT goes to mylogfile. In order to send the output to the terminal window again, sys.stdout must be set back to normal:
sys.stdout = normal_stdout
History
Date User Action Args
2016-04-01 19:47:31janis.slapinssetrecipients: + janis.slapins, vinay.sajip
2016-04-01 19:47:31janis.slapinssetmessageid: <1459540051.67.0.836733968292.issue26606@psf.upfronthosting.co.za>
2016-04-01 19:47:31janis.slapinslinkissue26606 messages
2016-04-01 19:47:31janis.slapinscreate