Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #12754
| From | markspace <-@.> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: Question about loggers |
| Date | 2012-03-07 15:21 -0800 |
| Organization | A noiseless patient Spider |
| Message-ID | <jj8qh3$ufb$1@dont-email.me> (permalink) |
| References | <XnsA00FACCA4B5E9jpnasty@94.75.214.39> |
On 3/7/2012 1:52 PM, Novice wrote:
> My impression from the "Aspect Questions" thread was that the "best
> practices" approach to logging was to use named loggers, where, in essence,
> each method that needs to write to the log creates a named logger via
>
> Logger logger = Logger.getLogger(getClass().getName());
I could see an app that was divided into functional parts, like maybe
"DATABASE" and "GUI", etc. where the logging was specified to use those
names:
Logger log = Logger.getLogger( "GUI" );
But while I could see this, I've never actually heard of anyone
specifying it. Loggers by class name is all I've ever seen.
>
> Also, Stelting mentions that you can use the LogManager to "cache Logger
> objects for repeat use". What circumstances would justify using LogManager?
> I was under the impression that simply doing Logger.getLogger() was
> perfectly adequate for a professional quality program. Why would LogManager
> be any better than simply making the logger a class variable?
I think I've done this, exactly once in my life:
public class MyLogger extends Logger {
...
}
...
MyLogger log = new MyLogger();
LogManager.getLogManager().addLogger( log );
If you go through the Logger.getLogger( name ) method this is done for
you. If you make your own logger for some reason, you can still use the
LogManger to cache it.
> Then, I wrote a version using a named logger and a single class variable
> and the whole thing looks a lot simpler and cleaner:
It's kind of six of one and half dozen of another. Do what makes you
happiest. But assume any given shop might have different ideas what is
best, and be prepared to adjust.
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar
Question about loggers Novice <novice@example..com> - 2012-03-07 21:52 +0000
Re: Question about loggers Arne Vajhøj <arne@vajhoej.dk> - 2012-03-07 17:16 -0500
Re: Question about loggers Novice <novice@example..com> - 2012-03-07 23:57 +0000
Re: Question about loggers Arne Vajhøj <arne@vajhoej.dk> - 2012-03-07 19:24 -0500
Re: Question about loggers Lew <noone@lewscanon.com> - 2012-03-08 07:22 -0800
Re: Question about loggers Arne Vajhøj <arne@vajhoej.dk> - 2012-03-08 10:27 -0500
Re: Question about loggers Lew <lewbloch@gmail.com> - 2012-03-08 11:58 -0800
Re: Question about loggers Arne Vajhøj <arne@vajhoej.dk> - 2012-03-08 15:49 -0500
Re: Question about loggers Robert Klemme <shortcutter@googlemail.com> - 2012-03-08 08:15 -0800
Re: Question about loggers markspace <-@.> - 2012-03-08 10:05 -0800
Re: Question about loggers Arne Vajhøj <arne@vajhoej.dk> - 2012-03-08 13:50 -0500
Re: Question about loggers Robert Klemme <shortcutter@googlemail.com> - 2012-03-09 07:11 -0800
Re: Question about loggers Lew <noone@lewscanon.com> - 2012-03-09 07:45 -0800
Re: Question about loggers markspace <-@.> - 2012-03-09 07:54 -0800
Re: Question about loggers Arne Vajhøj <arne@vajhoej.dk> - 2012-03-09 11:03 -0500
Re: Question about loggers markspace <-@.> - 2012-03-09 09:10 -0800
Re: Question about loggers Arne Vajhøj <arne@vajhoej.dk> - 2012-03-09 12:27 -0500
Re: Question about loggers Lew <lewbloch@gmail.com> - 2012-03-09 10:56 -0800
Re: Question about loggers Robert Klemme <shortcutter@googlemail.com> - 2012-03-09 20:29 +0100
Re: Question about loggers Arne Vajhøj <arne@vajhoej.dk> - 2012-03-09 11:04 -0500
Re: Question about loggers markspace <-@.> - 2012-03-09 09:14 -0800
Re: Question about loggers Arne Vajhøj <arne@vajhoej.dk> - 2012-03-09 12:22 -0500
Re: Question about loggers Lew <lewbloch@gmail.com> - 2012-03-09 10:58 -0800
Re: Question about loggers markspace <-@.> - 2012-03-07 15:21 -0800
Re: Question about loggers Novice <novice@example..com> - 2012-03-08 00:01 +0000
Re: Question about loggers Arne Vajhøj <arne@vajhoej.dk> - 2012-03-07 19:21 -0500
Re: Question about loggers Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2012-03-08 06:18 -0400
csiph-web