[slf4j-dev] Category of Logger vs. name of containing class.
Endre Stølsvik
Endre at Stolsvik.com
Mon Jul 11 10:24:37 CEST 2005
Hi!
Reading the emails about markers, levels and categorization, I was
wondering: is there a good reason for sticking with using the class name
as the category name, other than convenience?
The reason for asking, is that I feel that several of the suggestions
seems to be kinda assume that the category of the logger is already "used
up" for the name of the class, so that it cannot be used for other
categorization outside of the existing categorization already made by the
java package-and-classname hierarchy.
You can already get the actual classname (and method) of a log statement
by using the introspection (formatting) methods, at least in log4j and
java.util.logging. Thus using the category of the Logger for this seems to
me as waste of identification-space - a whole axis: It is redundant
information.
Obviously, one wouldn't want the class-extraction features to be used in
a production environemnt, due to the (rather heavy) overhead of extracting
it. However, log configs can be changed easily, and if you make provisions
for it, even runtime. Thus if you can't track back a log-line to the point
where it was made (the class), then you can turn on these features in your
log-config, and thus extract them. However, it is seldom that I have had
to turn to such measures, at least when working with my own codebase.
Endre.
More information about the slf4j-dev
mailing list