<p>Hi,</p>
<p>except not able to caught the TypeError exception occured in the below<br>code</p>
<p>       <a href="http://log.info">log.info</a>("refer",ret) in the try block</p>
<p>throws a TypeError which is not caught .<br>Also sometimes process is getting hanged.</p>
<p>------------------------------------------------------------------------------------------------------------------------------------------------<br>import logging<br>log = logging.getLogger()<br>fileName = strftime("%d-%b-%Y-", gmtime()) + str(int(time.time())) + "-<br>
Log.log"<br>log = logging.getLogger()<br>log.setLevel(logging.NOTSET)<br>fh = logging.FileHandler(logFile)<br>logFileLevel = logging.DEBUG<br>fh.setLevel(logFileLevel)<br>format_string = '%(process)d %(thread)d %(asctime)-15s %(levelname)-5s<br>
at %(filename)-15s in %(funcName)-10s at line %(lineno)-3d "%(message)<br>s"'<br>fh.setFormatter(logging.Formatter(format_string))<br>log.addHandler(fh)</p>
<p>try:<br>   <a href="http://log.info">log.info</a>("start")<br>   <a href="http://log.info">log.info</a>("refer",ret)<br>   <a href="http://log.info">log.info</a>("end")<br>except TypeError:<br>
   log.exception("Exception raised")</p>
<p>----------------------------------------------------------------------------------------------------------------------------------------------<br>OUTPUT message:</p>
<p>Traceback (most recent call last):<br> File "C:\Python26\lib\logging\__init__.py", line 768, in emit<br>   msg = self.format(record)<br> File "C:\Python26\lib\logging\__init__.py", line 648, in format<br>
   return fmt.format(record)<br> File "C:\Python26\lib\logging\__init__.py", line 436, in format<br>   record.message = record.getMessage()<br> File "C:\Python26\lib\logging\__init__.py", line 306, in getMessage<br>
   msg = msg % self.args<br>TypeError: not all arguments converted during string formatting</p>