The ``args`` entry, when :func:`eval`\ uated in the context of the ``logging``
package's namespace, is the list of arguments to the constructor for the handler
class. Refer to the constructors for the relevant handlers, or to the examples
-below, to see how typical entries are constructed.
+below, to see how typical entries are constructed. If not provided, it defaults
+to ``()``.
+
+The optional ``kwargs`` entry, when :func:`eval`\ uated in the context of the
+``logging`` package's namespace, is the keyword argument dict to the constructor
+for the handler class. If not provided, it defaults to ``{}``.
.. code-block:: ini
level=WARN
formatter=form07
args=('localhost', 'from@abc', ['user1@abc', 'user2@xyz'], 'Logger Subject')
+ kwargs={'timeout': 10.0}
[handler_hand08]
class=handlers.MemoryHandler
level=NOTSET
formatter=form09
args=('localhost:9022', '/log', 'GET')
+ kwargs={'secure': True}
Sections which specify formatter configuration are typified by the following.
klass = eval(klass, vars(logging))
except (AttributeError, NameError):
klass = _resolve(klass)
- args = section["args"]
+ args = section.get("args", '()')
args = eval(args, vars(logging))
- h = klass(*args)
+ kwargs = section.get("kwargs", '{}')
+ kwargs = eval(kwargs, vars(logging))
+ h = klass(*args, **kwargs)
if "level" in section:
level = section["level"]
h.setLevel(level)
datefmt=
"""
- # config7 adds a compiler logger.
+ # config7 adds a compiler logger, and uses kwargs instead of args.
config7 = """
[loggers]
keys=root,parser,compiler
class=StreamHandler
level=NOTSET
formatter=form1
- args=(sys.stdout,)
+ kwargs={'stream': sys.stdout,}
[formatter_form1]
format=%(levelname)s ++ %(message)s