Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #12449

Re: Additional logging questions

From Daniel Pitts <newsgroup.nospam@virtualinfinity.net>
Newsgroups comp.lang.java.programmer
Subject Re: Additional logging questions
References <XnsA005D74257FB0jpnasty@94.75.214.39>
Message-ID <GPR2r.17474$yb.17398@newsfe20.iad> (permalink)
Date 2012-02-27 12:36 -0800

Show all headers | View raw


On 2/26/12 6:02 PM, Novice wrote:
> I _think_ these supplementary questions will be a lot less of a struggle
> than the others in "Aspect questions" thread. That thread is getting on
> the long side so I thought I'd ask these in a new thread.
>
> Basically, I'm looking for advice on what should always be logged by
> every class. I understand now that every class is going to have its own
> logger but what should be logged?
>
> Or to put it another way, are there cases where a class won't log at all?

Classes don't log, methods log. The question then becomes, which methods 
should (or shouldn't) log.

What I've determined is that you need to ask yourself a series of questions.

Would logging at this point be useful at all?
Who would it be useful for? Developers, Operations, and/or business?
How much information should I include? Just a message stating an event 
happened? Metrics about that event? Details about all objects involved?
What log level should I use?

For example, if you think a Developer needs this information, but no one 
else does, then a "debug" level log with all relevant details makes 
sense.  Operations and/or business probably just want metrics. 
Operations just want errors or severe warnings.

Also, depending on where the code runs, you may enable/disable certain 
levels of logging.  Production probably only warnings/errors should be 
enabled after start up, and info should be enabled only during start-up. 
In UAT/QA, more information seems useful. Enabling debug makes sense in 
DEV environments, *or* when you have a problem you can't reproduce in a 
dev environment.

It is also possible (though rare) to have a class have multiple loggers. 
  I can think of exactly one use-case, but there may be more.  That 
use-case is specifically for metric logging. If you have some metrics 
your code collects to log, then it might make sense to separate those 
out into there own "log stream".

Hope this helps,
Daniel.

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Additional logging questions Novice <novice@example..com> - 2012-02-27 02:02 +0000
  Re: Additional logging questions Arne Vajhøj <arne@vajhoej.dk> - 2012-02-26 21:08 -0500
    Re: Additional logging questions Novice <novice@example..com> - 2012-02-27 04:12 +0000
      Re: Additional logging questions Lew <noone@lewscanon.com> - 2012-02-26 22:13 -0800
        Re: Additional logging questions Novice <novice@example..com> - 2012-02-27 19:14 +0000
          Re: Additional logging questions Lew <noone@lewscanon.com> - 2012-02-27 12:32 -0800
          Re: Additional logging questions Lew <noone@lewscanon.com> - 2012-02-27 13:06 -0800
            Re: Additional logging questions Novice <novice@example..com> - 2012-02-28 01:48 +0000
              Re: Additional logging questions Arne Vajhøj <arne@vajhoej.dk> - 2012-02-27 20:57 -0500
                Re: Additional logging questions Lew <noone@lewscanon.com> - 2012-02-27 23:51 -0800
          Re: Additional logging questions Arne Vajhøj <arne@vajhoej.dk> - 2012-02-27 20:50 -0500
            Re: Additional logging questions Lew <noone@lewscanon.com> - 2012-02-27 23:57 -0800
        Re: Additional logging questions Arne Vajhøj <arne@vajhoej.dk> - 2012-02-27 20:45 -0500
          Re: Additional logging questions Leif Roar Moldskred <leifm@dimnakorr.com> - 2012-02-28 01:52 -0600
            Re: Additional logging questions Arne Vajhøj <arne@vajhoej.dk> - 2012-02-28 17:20 -0500
            Re: Additional logging questions Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2012-02-28 20:26 -0400
      Re: Additional logging questions Arne Vajhøj <arne@vajhoej.dk> - 2012-02-27 20:34 -0500
  Re: Additional logging questions Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2012-02-27 12:36 -0800
    Re: Additional logging questions Novice <novice@example..com> - 2012-02-28 01:43 +0000

csiph-web