Which is Superior- Logging Or Debugging

V

vnssoftware

Hi,

Just wanted to get feedback on what most people think is better-

Logging: Includes any Log API/Methods you use
Debugging: Includes using Breakpoint, Step Into etc with Debugger

This is specifically from Java Viewpoint.

Thanks for your responses.
 
R

Roedy Green

Logging: Includes any Log API/Methods you use
Debugging: Includes using Breakpoint, Step Into etc with Debugger

Which is better sex or ice cream? A good life has both.
 
R

Robert Olofsson

vnssoftware ([email protected]) wrote:
: Just wanted to get feedback on what most people think is better-
: Logging: Includes any Log API/Methods you use
: Debugging: Includes using Breakpoint, Step Into etc with Debugger
: This is specifically from Java Viewpoint.

You also has to understand that there may be different uses for
logging and debugging. A well build logging system may be used on the
production server without a performance hit unless the log-level is
high enough in the config file/database config table.
Trying to convince the boss that I should run the debugger on the
production server is never an option wheres turning on more logging
may be easily accomplished.

NOTE: debugging or logging on the production server is not something I
do regurarly. It is not a thing that should be done!

Anyway under development I use both, where logging may be
System.err.println during bug hunting. A problem with the debugger may
be that it causes the race conditions to never occur due to the extra
cycles used for the debugger. It also depends on the problem you try
to solve. Anyway I have not yet found a java debugger that I really
like so I tend to log more...

/robo
 
S

Scott Ellsworth

Hi,

Just wanted to get feedback on what most people think is better-

Logging: Includes any Log API/Methods you use
Debugging: Includes using Breakpoint, Step Into etc with Debugger

This is specifically from Java Viewpoint.

Thanks for your responses.

They are both very useful in the proper circumstance.

General logging gives you an easy way to see just what your code is
doing, and to log that it is, indeed, doing the right things when
running your unit tests.

Logging that includes timing, call count, other benchmarking options can
be a very good way to highlight strange behaviors in your code without
having to run a profiler on a customer machine.

A debugger is probably the best way to track down a single point failure
- bring the code up in the debugger, track down what it is doing at the
point of failure, examine needed variables, and fix the problem. Very
quick, and very efficient.

I have found debugging works better for WebObjects, but extensive
logging works better for most long executing code.

For me, the key questions are:

1. Will I be able to run a debugger on systems showing a problem.
2. Will I be able to run a profiler on systems showing a problem
3. Is my customer adept enough to run with a special extended logger
file in place to gather data I need.
4. Is logging lightweight enough to capture needed information on every
run, or must it be something only activated at need.

Scott
 
J

James Wilson

vnssoftware said:
Hi,

Just wanted to get feedback on what most people think is better-

Logging: Includes any Log API/Methods you use
Debugging: Includes using Breakpoint, Step Into etc with Debugger

This is specifically from Java Viewpoint.

Thanks for your responses.

I use both but for completely different reasons. IMHO, logging is a
requirement. A debugger is a luxury. My goal when programming is to
write code as well as I can the first time and that requires logging so
that you can view what's happening or not happening when the program is
running (at "full speed"). I find that the more logging I do the less I
need a debugger because my logging shows me the state of the program's
execution at each level, so when an exception is thrown and subsequently
logged I know the circumstances involved. I use a debugger only during
development and only after my logging doesn't clue me into what needs to
be fixed. One of the best virtues of logging, as others have already
noted, is that it's forever. Under the load of a live system logging is
worth is weight in gold and debuggers are inconsequential. Programmers
that rely on debuggers and do not log at all ultimately produce software
that maximizes downtime and minimizes maintainability.

Log4J is good but JDK 1.4 logging will suffice for almost anything.

JBuilder9 has a debugger that is fair. The "on the fly" code
regeneration during a debug session is nice if it only worked a little
better.

Ofcourse, this is all IMHO. :)

James
 
W

Wei Jiang

Hi,

Just wanted to get feedback on what most people think is better-

Logging: Includes any Log API/Methods you use
Debugging: Includes using Breakpoint, Step Into etc with Debugger

This is specifically from Java Viewpoint.

Thanks for your responses.

You can not debug on production. A good logging allows you to do
source code level tracing. See SuperLogging at:
http://www.acelet.com/super/SuperLogging/index.html
 
V

vnssoftware

Conclusions:
1. Logging is a MUST HAVE.
2. Use Debugger only when Logging Cannot Help- though you can increase
logging if you have the source code.
3. Logging is more permanent.

These are view with respect to Java.

Thanks everyone for your inputs.
 
D

Douwe

Hi,

Just wanted to get feedback on what most people think is better-

Logging: Includes any Log API/Methods you use
Debugging: Includes using Breakpoint, Step Into etc with Debugger

This is specifically from Java Viewpoint.

Thanks for your responses.

I mostly use only logging. But using logging can have one realy big
disadvantage namely performance. Look at the next very simple, and
maybe stupid, for loop:

for(int i=0; i<1000; i++) {
e = e + i;
logger.detail("current value is " + i + " e=" + e);
}

If you would put the logger.level on 0 i.e. in a production
environment (which means the line is not logged at all) then still the
String argument is completly build (in case i is 0 this means the
String "current value is 0 e=0" would be created). This is all because
of the fact that the level is checked at the moment the program has
entered the logger's method detail. Instead I always use the next
construction:

for(int i=0; i<1000; i++) {
e = e + i;
if (logger.checkLevel(logger.DETAIL)) logger.log("current value
is " + i + " e=" + e);
}

But one should always be carefull to put to much logging in small
loops.

The disadvantage of a debugger that you analyse a part of code just
ones (namely only when their is a bug) .... if the bug is solved you
stop the debugger and that's it. If you instead would have put logging
in your code, this logging would still exist and next time their is a
bug you already have the logging information.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,480
Members
44,900
Latest member
Nell636132

Latest Threads

Top