.. versionadded:: 3.2
-.. function:: fileConfig(fname, defaults=None, disable_existing_loggers=True)
+.. function:: fileConfig(fname, defaults=None, disable_existing_loggers=True, encoding=None)
Reads the logging configuration from a :mod:`configparser`\-format file. The
format of the file should be as described in
they or their ancestors are explicitly named
in the logging configuration.
+ :param encoding: The encoding used to open file when *fname* is filename.
+
.. versionchanged:: 3.4
An instance of a subclass of :class:`~configparser.RawConfigParser` is
now accepted as a value for ``fname``. This facilitates:
application (e.g. based on command-line parameters or other aspects
of the runtime environment) before being passed to ``fileConfig``.
+ .. versionadded:: 3.10
+ The *encoding* parameter is added.
+
.. function:: listen(port=DEFAULT_LOGGING_CONFIG_PORT, verify=None)
Starts up a socket server on the specified port, and listens for new
# _listener holds the server object doing the listening
_listener = None
-def fileConfig(fname, defaults=None, disable_existing_loggers=True):
+def fileConfig(fname, defaults=None, disable_existing_loggers=True, encoding=None):
"""
Read the logging configuration from a ConfigParser-format file.
if hasattr(fname, 'readline'):
cp.read_file(fname)
else:
- cp.read(fname)
+ encoding = io.text_encoding(encoding)
+ cp.read(fname, encoding=encoding)
formatters = _create_formatters(cp)