pythonloggingconfiguration

Pass keyword arg to log handler in python logging configuration file


According to https://docs.python.org/2/library/logging.config.html#configuration-file-format I can specify arguments to the constructor of a logger, by using the args key. But this seems to work only for positional arguments. I have a handler which needs some keyword arguments. Is there a way to specify those in the config file?


Solution

  • I'm sorry to tell you that the answer is no.

    Have a look at https://github.com/python/cpython/blob/v2.7.18/Lib/logging/config.py#L163 for more details.

    When in doubt, the source code is always your friend!