Jānis Šlapiņš added the comment:

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

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue26606>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to