[slf4j-dev] [Bug 257] Recommended Logger Name

bugzilla-daemon at qos.ch bugzilla-daemon at qos.ch
Wed May 9 22:19:29 CEST 2012


http://bugzilla.slf4j.org/show_bug.cgi?id=257

--- Comment #4 from Joachim Durchholz <jo at durchholz.org> 2012-05-09 22:19:28 CEST ---
While an aircraft carrier is quite different from a motorboat, you still don't
use aluminium for the wiring.
Argument by analogy doesn't fly, you always need to justify why your analogy
holds and why the other doesn't - IOW you need to argue substance anyway and
the analogy doesn't help a bit.

Why using logger names is a bad idea:
- You say you need to identify the product in the log message. Then you say you
need to identify the business entity. You're trying to stuff quite a lot of
very different things into the same name here. Plus, there's always a lot of
code that doesn't quite fit the classification of "product" or "business
entity".
- Logger names are hierarchical for a reason: they eliminate the need to
reconfigure logging for different modules, you can factor out configuration
from submodules into supermodules. You lose that if you switch to a flat
"product" namespace.
- Identifying the business entity often isn't enough, you also need the ID
(customer ID etc.). You can't put dynamic data into the logger name, so that
use case isn't covered by your approach.
- Any third-party software that you use will have hardcoded classnames in its
loggers. You'll get a hodgepodge of class names and product names in your logs.

Why not put product/whatever names into the log message text?
You can always create your own logging framework. A thin layer above Logger
that has warn(String moduleName, String message, Object... params) that does
warn(moduleName + ": " + message, params). (There are ways to optimize that.)

BTW I *have* scoured log messages. Knowing the class name is helpful.
I'm also seeing people blog about moving from non-classname logger names back
to classname-based ones, but not the other way round.

Have mercy on your developers. There are better ways to achieve what you want.
'nuff said.

-- 
Configure bugmail: http://bugzilla.slf4j.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.


More information about the slf4j-dev mailing list