Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion Doc/library/logging.config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ in :mod:`logging` itself) and defining handlers which are declared either in

.. 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
Expand Down Expand Up @@ -111,6 +111,8 @@ in :mod:`logging` itself) and defining handlers which are declared either 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:
Expand All @@ -121,6 +123,9 @@ in :mod:`logging` itself) and defining handlers which are declared either in
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
Expand Down
5 changes: 3 additions & 2 deletions Lib/logging/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
# _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.

Expand All @@ -66,7 +66,8 @@ def fileConfig(fname, defaults=None, disable_existing_loggers=True):
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)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add an ``encoding`` parameter :func:`logging.fileConfig()`.