Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #20953
| X-Received | by 10.66.90.67 with SMTP id bu3mr9607701pab.45.1357328175141; Fri, 04 Jan 2013 11:36:15 -0800 (PST) |
|---|---|
| Received | by 10.50.191.131 with SMTP id gy3mr17808957igc.1.1357328175082; Fri, 04 Jan 2013 11:36:15 -0800 (PST) |
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!b8no3294068pbd.0!news-out.google.com!s9ni72755pbb.0!nntp.google.com!f6no10170994pbd.1!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail |
| Newsgroups | comp.lang.java.programmer |
| Date | Fri, 4 Jan 2013 11:36:14 -0800 (PST) |
| In-Reply-To | <veFFs.21649$6a5.5075@newsfe14.iad> |
| Complaints-To | groups-abuse@google.com |
| Injection-Info | glegroupsg2000goo.googlegroups.com; posting-host=69.28.149.29; posting-account=CP-lKQoAAAAGtB5diOuGlDQk0jIwmH0T |
| NNTP-Posting-Host | 69.28.149.29 |
| References | <e3230fa7-b672-49e0-a7ef-dfb55a9180b5@googlegroups.com> <kc6rjn$fl2$1@dont-email.me> <veFFs.21649$6a5.5075@newsfe14.iad> |
| User-Agent | G2/1.0 |
| MIME-Version | 1.0 |
| Message-ID | <cf3a089d-b15a-400f-9fa3-0ac37021350a@googlegroups.com> (permalink) |
| Subject | Re: dependency injection and loggers |
| From | Lew <lewbloch@gmail.com> |
| Injection-Date | Fri, 04 Jan 2013 19:36:15 +0000 |
| Content-Type | text/plain; charset=ISO-8859-1 |
| Xref | csiph.com comp.lang.java.programmer:20953 |
Show key headers only | View raw
Daniel Pitts wrote:
> On the other hand, there generally isn't any real requirement that
> loggers be static. I have had occasion to create a class which uses a
> different logger depending on the context in which that class was created.
>
> public class MySomething {
> private final Logger log;
>
> public MySomething() {
> this.log = Logger.getLogger(MySomething.class);
> }
>
> public MySomething(Logger log) {
> this.log = log;
> }
> }
If I have a class hierarchy (for when despite Josh Bloch's recommendation to "prefer composition
to inheritance" I go the other way) I will often put in the parent class:
private final Logger logger = Logger.getLogger(getClass().getName());
This despite the violation of "Don't call an overrideable method during construction."
:-)
--
Lew
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
dependency injection and loggers Tomer <tomerbd1@gmail.com> - 2013-01-04 04:00 -0800
Re: dependency injection and loggers markspace <markspace@nospam.nospam> - 2013-01-04 07:13 -0800
Re: dependency injection and loggers Kevin McMurtrie <mcmurtrie@pixelmemory.us> - 2013-01-04 09:18 -0800
Re: dependency injection and loggers Arne Vajhøj <arne@vajhoej.dk> - 2013-01-04 22:27 -0500
Re: dependency injection and loggers Wayne <nospam@all.invalid> - 2013-01-04 23:33 -0500
Re: dependency injection and loggers Arved Sandstrom <asandstrom2@eastlink.ca> - 2013-01-05 11:55 -0400
Re: dependency injection and loggers Kevin McMurtrie <mcmurtrie@pixelmemory.us> - 2013-01-05 10:01 -0800
Re: dependency injection and loggers Arne Vajhøj <arne@vajhoej.dk> - 2013-01-05 15:17 -0500
Re: dependency injection and loggers Arne Vajhøj <arne@vajhoej.dk> - 2013-01-05 16:37 -0500
Re: dependency injection and loggers Lew <lewbloch@gmail.com> - 2013-01-05 12:24 -0800
Re: dependency injection and loggers Arne Vajhøj <arne@vajhoej.dk> - 2013-01-05 16:41 -0500
Re: dependency injection and loggers Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2013-01-04 10:31 -0800
Re: dependency injection and loggers Lew <lewbloch@gmail.com> - 2013-01-04 11:36 -0800
Re: dependency injection and loggers Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2013-01-04 11:57 -0800
Re: dependency injection and loggers Arne Vajhøj <arne@vajhoej.dk> - 2013-01-04 22:28 -0500
Re: dependency injection and loggers Arne Vajhøj <arne@vajhoej.dk> - 2013-01-04 22:24 -0500
csiph-web