views:

105

answers:

4

Suppose, you have a special log table of your application.

What do you think about creating a BLOB field for a possible stack trace ?

Logging is done to file as well, but it is not so convenient to read a text file, moreover database is more "accessible".

+4  A: 

What if the stack trace is due to a database connection failure? Some things need to be as low-level and simple as possible. Also, I don't see why a database should be any more or less accessible than a file share or ssh account.

Marcelo Cantos
well it's only a duplicate log, not the main. The main log4j log file will be kept as well.
EugeneP
Still a good obvervation by @MarceloCantos.
Seventh Element
+1  A: 

I previously worked on an application where this happened, but as Marcelo Cantos suggests, it was never really reliable because certain exceptions couldn't be logged there, so we never used it and always relied on log files instead.

If you use the log file to debug errors, you'll also get any other debug of info messages you choose to print, in the correct order; it's rare that all you need is a stack trace, usually what led up to the stack trace is equally if not more useful.

DaveyDaveDave
+4  A: 

Duplicate logging sounds like... well, duplicate logging. Overhead. If you need to access the logs through database, I would rather use/write a tool that can import the logs to a separate database when needed. Or make them accessible by some other means. One tool that I know of is Splunk, but it's expensive and I'm sure there are others too.

fish
I was about to make this very suggestion
Chris Knight
+1  A: 

Why ? Or at least, if you're going to do it, why the Blob field ?

If I were to implement something like this, I would separate the exceptions into separate StackTraceElements and store those into a proper table. Over time and a variety of failures, you might generate some interesting statistics about the nature of risk and quality within your application.

Jim Rush
@Jim Rush Cause some db engines cannot hold more than 255 chars per char field.
EugeneP
@EugeneP Correct, I wasn't thinking of it so much as size item, but not having much ability to search the data. If it were me, I would allow searches by package, class and method. That combined with statistics from code coverage and testing tools might yield some interesting analytics.
Jim Rush