logging TypeError: not all arguments converted during string formatting

Peter Otten __peter__ at web.de
Thu Sep 15 12:49:09 EDT 2016


Daiyue Weng wrote:

> Hi, I am trying to record memory and CPU usages and load a logger from an
> external config file (logging.conf),

[snip]

One important debugging strategy is to try and find the minimal example that 
produces a problem. In this case you can provoke the the behaviour you are 
seeing with two lines of Python:

>>> import logging
>>> logging.warn(1, 2)
--- Logging error ---
Traceback (most recent call last):
  File "/usr/lib/python3.4/logging/__init__.py", line 978, in emit
    msg = self.format(record)
  File "/usr/lib/python3.4/logging/__init__.py", line 828, in format
    return fmt.format(record)
  File "/usr/lib/python3.4/logging/__init__.py", line 565, in format
    record.message = record.getMessage()
  File "/usr/lib/python3.4/logging/__init__.py", line 328, in getMessage
    msg = msg % self.args
TypeError: not all arguments converted during string formatting
Call stack:
  File "<stdin>", line 1, in <module>
Message: 1
Arguments: (2,)

Please make an effort to remove the irrelevant stuff before you come here to 
ask for help next time. Thank you.




More information about the Python-list mailing list