Unusual Exception Behaviour

Robert Rawlins robert.rawlins at thinkbluemedia.co.uk
Thu Jul 17 18:52:05 CEST 2008


Hi MK,

>>Robert Rawlins wrote:
>>
>> I certainly like that implementation for logging the exceptions, however,
at
>> the moment I don't even know where the exceptions are occurring, or what
>> type they are, could I still use this method to log any and all
exceptions
>> raised in the application? 

> Remember, Google is your friend, here's the crux of the method without 
> the fancy schmancy sugar coating:
>
>
http://linux.byexamples.com/archives/365/python-convey-the-exception-traceba
ck-into-log-file/
>
> if __name__=="__main__":
>      try:
>          main()
>      except:
>          print "Trigger Exception, traceback info forward to log file."
>          traceback.print_exc(file=open("errlog.txt","a"))
>          sys.exit(1)
>

I've just given this solution a shot but I still seem to get the same
result, it suddenly starts dumping the log data to the command line, and
nothing gets printed in error.txt apart from the keyboard interrupt from
when I kill the application.

For some reason the exceptions don't seem to be raised properly so obviously
aren't being caught at this higher level.

So confusing.




More information about the Python-list mailing list