Don't use commons-logging

12 views
Skip to first unread message

Moandji Ezana

unread,
Jun 4, 2013, 12:07:37 AM6/4/13
to illegalargument

Not that I use it, but what was the reason behind this advice?

mP

unread,
Jun 12, 2013, 6:07:13 AM6/12/13
to illegal...@googlegroups.com
I said it before and ill say it again. If you use logging your doing it wrong. Logging is used haphazardly in too many classes. It should at best only appear in a few key classes. You dont see logging in String, StringBuilder or any of the key jdk classes so why do people include it everywhere ?

Mark Derricutt

unread,
Jun 12, 2013, 6:59:51 AM6/12/13
to illegal...@googlegroups.com
As mentioned on the follow-up UO recording, we mentioned some of the reasons:

- CL uses ( or used? ) classpath scanning to choose which implementation to use, rather than how slf4j has concrete implementations in each dependency - i.e. slf4j-log4j has all the logging implementation for log4j, so you just include that dep along with core, I believe they share the same class names ( which kinda feels evil ) but I could be wrong?

Richard also mentioned there was threading issues with CL I think...

mP wrote:
--

---
You received this message because you are subscribed to the Google
Groups "illegalargument" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to illegalargume...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Moandji Ezana

unread,
Jun 12, 2013, 7:02:28 AM6/12/13
to illegalargument

Yes, thanks for the explanation.

mP: I tend to agree, but do you then instrument the code in some way to be able to figure out what's going on?

Moandji Ezana

unread,
Jun 12, 2013, 7:04:25 AM6/12/13
to illegalargument
Logging during a bootstrap phase is often useful, however. As well as in libraries or frameworks (eg. logging Hibernate queries), as long as it's easy to shut off.

I think haphazard logging applies most to application-level code.

mP

unread,
Jun 12, 2013, 10:36:29 PM6/12/13
to illegal...@googlegroups.com
Well firstly you should pass a Logger as a dependency and not hardcode it via a static field. Most the pain mentioned in this thread relate to the discovery process. Lastlty logging adds clutter to frameworks. Take a look at something like Hibernate or any other biggish library and nearly half the code is related to logging. Theres the logger field, tests to determine if logging is enabled and then building of strings.
Reply all
Reply to author
Forward
0 new messages