Which is Superior- Logging Or Debugging

Discussion in 'Java' started by vnssoftware, Aug 21, 2003.

  1. vnssoftware

    vnssoftware Guest

    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.
     
    vnssoftware, Aug 21, 2003
    #1
    1. Advertising

  2. vnssoftware

    Roedy Green Guest

    On 21 Aug 2003 11:47:11 -0700, (vnssoftware)
    wrote or quoted :

    >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.

    --
    Canadian Mind Products, Roedy Green.
    Coaching, problem solving, economical contract programming.
    See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
     
    Roedy Green, Aug 21, 2003
    #2
    1. Advertising

  3. vnssoftware () 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
     
    Robert Olofsson, Aug 21, 2003
    #3
  4. vnssoftware

    xarax Guest

    Roedy Green <> wrote in message news:<>...
    > On 21 Aug 2003 11:47:11 -0700, (vnssoftware)
    > wrote or quoted :
    >
    > >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.


    Better would be sex WITH ice cream...
     
    xarax, Aug 22, 2003
    #4
  5. vnssoftware

    vnssoftware Guest

    vnssoftware, Aug 22, 2003
    #5
  6. In article <>,
    (vnssoftware) wrote:

    > 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
     
    Scott Ellsworth, Aug 22, 2003
    #6
  7. vnssoftware

    James Wilson Guest

    vnssoftware wrote:

    > 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
     
    James Wilson, Aug 25, 2003
    #7
  8. vnssoftware

    Wei Jiang Guest

    (vnssoftware) wrote in message news:<>...
    > 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
     
    Wei Jiang, Aug 26, 2003
    #8
  9. vnssoftware

    vnssoftware Guest

    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.
     
    vnssoftware, Aug 26, 2003
    #9
  10. vnssoftware

    Douwe Guest

    (vnssoftware) wrote in message news:<>...
    > 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.
     
    Douwe, Aug 27, 2003
    #10
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. John Sedlak
    Replies:
    6
    Views:
    357
    John Sedlak
    Nov 4, 2003
  2. Öö Tiib
    Replies:
    11
    Views:
    483
    Öö Tiib
    May 20, 2010
  3. Joseph M. Newcomer
    Replies:
    31
    Views:
    913
    Oliver Regenfelder
    May 21, 2010
  4. Joseph M. Newcomer
    Replies:
    0
    Views:
    527
    Joseph M. Newcomer
    May 17, 2010
  5. Lynn McGuire

    Why C++ is vastly superior to C

    Lynn McGuire, May 16, 2011, in forum: C++
    Replies:
    230
    Views:
    3,975
Loading...

Share This Page