siddhartha veedaluru wrote: > Hi, > > except not able to caught the TypeError exception occured in the below > code > > log.info <http://log.info>("refer",ret) in the try block > > throws a TypeError which is not caught .
The traceback you provide does not show the line in question, so I am confused as to why you would think it was causing the problem. The purpose of the traceback is to show you where the exception occurred, and I question whether that is happening here. Anyway, I suspect your error might go away if you turned the first argument of hte log.info() call into a format string such as log.info("refer: %s", ret) regards Steve > Also sometimes process is getting hanged. > > ------------------------------------------------------------------------------------------------------------------------------------------------ > import logging > log = logging.getLogger() > fileName = strftime("%d-%b-%Y-", gmtime()) + str(int(time.time())) + "- > Log.log" > log = logging.getLogger() > log.setLevel(logging.NOTSET) > fh = logging.FileHandler(logFile) > logFileLevel = logging.DEBUG > fh.setLevel(logFileLevel) > format_string = '%(process)d %(thread)d %(asctime)-15s %(levelname)-5s > at %(filename)-15s in %(funcName)-10s at line %(lineno)-3d "%(message) > s"' > fh.setFormatter(logging.Formatter(format_string)) > log.addHandler(fh) > > try: > log.info <http://log.info>("start") > log.info <http://log.info>("refer",ret) > log.info <http://log.info>("end") > except TypeError: > log.exception("Exception raised") > > ---------------------------------------------------------------------------------------------------------------------------------------------- > OUTPUT message: > > Traceback (most recent call last): > File "C:\Python26\lib\logging\__init__.py", line 768, in emit > msg = self.format(record) > File "C:\Python26\lib\logging\__init__.py", line 648, in format > return fmt.format(record) > File "C:\Python26\lib\logging\__init__.py", line 436, in format > record.message = record.getMessage() > File "C:\Python26\lib\logging\__init__.py", line 306, in getMessage > msg = msg % self.args > TypeError: not all arguments converted during string formatting > -- Steve Holden +1 571 484 6266 +1 800 494 3119 PyCon is coming! Atlanta, Feb 2010 http://us.pycon.org/ Holden Web LLC http://www.holdenweb.com/ UPCOMING EVENTS: http://holdenweb.eventbrite.com/ -- http://mail.python.org/mailman/listinfo/python-list