473,386 Members | 1,705 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Re: Log Exception with Backtrace

On Fri, Oct 17, 2008 at 9:40 AM, Heston James - Cold Beans
<he**********@coldbeans.co.ukwrote:
Afternoon Guys,

I'm currently logging exceptions within my applications like so:

try:
#do something....
except Exception, error:
# Log the exception.
self.logger.error("Exception Occurred: (%s)" % str(error))
This is quite fine, however, sometimes I get very vague error message thrown
at me which don't help a great deal. How can I log the full exception and
backtrace as if it were thrown to stderr and I wasn't catching it?
Use format_exc() in the 'traceback' module to get a string for the
current stack trace (and exception) and log that.

Cheers,
Chris
--
Follow the path of the Iguana...
http://rebertia.com
>
Cheers all,
Heston

--
http://mail.python.org/mailman/listinfo/python-list
Oct 17 '08 #1
0 1082

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: dsclements | last post by:
>Description: I'm running mysql in a 3 server configuration, with 2 servers being slaves to the first. I'm running vpopmail, which means a connection every incoming mail and every check. I woke up...
11
by: Mike - EMAIL IGNORED | last post by:
On FC4 with g++ using STL and Posix threads and sockets I am catching an exception that is not a std::exception. Any idea what it might be? An outline of my catch macro is below. Thanks,...
0
by: coolvinayak | last post by:
The backtrace() provides complete stacktrace. Using backtrace_symbols(), stacktrace can be printed as: ./build/gtest(func1_name+0x129) ./build/gtest(func2_name+0x193) ...
5
by: Nebur | last post by:
I'm using the contract.py library, running Python 2.4.4. Now I'm confronted with the following exception backtrace: (...) File "/usr/lib/python2.4/site-packages/contract.py", line 1265, in...
4
by: Chris Allen | last post by:
I am confused on one aspect of exception handling. If you specify the exception object type to match in an except statement it is possible to also obtain the exception object itself, but I can't...
7
by: Yarco | last post by:
Well, friend. Yes, I'm doing PHP. But exception is a traditional machinism in programming languages. I'm very doubt about this. In procedure language, we return error code when we meet an error. So...
3
by: cgable2003 | last post by:
I copied this code fragment from http://www.gnu.org/software/libc/manual/html_node/Backtraces.html #include <execinfo.h> #include <stdio.h> #include <stdlib.h> /* Obtain a backtrace and print...
18
by: sophia | last post by:
Dear all, can any one suggest ways of implementing a backtrace function in ANSI/ standard C as given in the following link ? ...
16
by: john6630 | last post by:
Coming from the .Net world, I am used to the try...catch...finally approach to error handling. And PHP 5 now supports this approach. But I am not clear what happens to unhandled errors/exceptioins?...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.