There is no real objection to this, except that it's a "hard"
cut-and-paste problem to go and re-do every logging statement in every
class everywhere.
Once Andrea and Martin decided to go directly with log4j (or
whatever...they just picked log4j because it made sense to them) they
decided that the EASY way to get every class everywhere using log4j (or
whatever) was to use a syntactic change like so:
OLD CODE: Logger _logger =
java.util.logging.Logger.getLogger("classname");
NEW CODE: Logger _logger =
org.geotools.util.Logging.getLogger("classname");
This was deemed (rightly in my eyes!) as an easier change to make across
the entire geotools codebase, and an easy one to document and implement.
Now what would this org.geotools.util.Logging.getLogger(String) method
return?
Well, it would return a subclass of "java.util.logger.Logger" that just
straight redirects EVERYTHING to log4j (or slf4j or whatever). It would
just call straight through, mapping all the relevant calls including the
EXTREMELY important "isLoggable()" call, right through to whatever the
underlying logging mechanism is.
This way we don't have to do an enormous amount of re-coding inside
geotools, all the code stays largely the same, and the end result is
almost exactly the same.
The added bonus is that we can make the
"org.geotools.util.Logging.getLogger(string)" method return various
different Logger subclasses. It could return a Logger that sends
everything straight through to log4j. It could return a Logger that
sends everything straight through to slf4j. It could return a logger
that sends everything straight through to Eclipse RCP trace events.
Etc.
Here's the short recap:
1) java.util.logging.* has a VERY rich interface for supporting lots of
log-related things like i18n, resourcebundles and stack traces.
2) No other logging framework has everything that java.util.logging.*
has (probably for a good reason!)
3...and this one's the clincher) Geotools USES lots of the stuff from 1
(like all of Martin's code).
The specific wins of Andreas and Martin's proposal is this:
* Dumping 1 and going to 2 is a painful CODING process. Not just a
cut-n-paste (in my opinion) or a sed/awk experience.
* Andrea and Martin's solution is simply an acceptance of the fact that
lots of Geotools code uses java.util.logging.* classes, and it would be
a lot of grunt search-and-replace to fix it. We've got enough grunt
search-and-replace(-and-test) coding on our plates already (filters,
featuremodel, geoapi, gce).
In the end I think the biggest concern is about hacks. Is subclassing
java.util.logging.Logger in this way a hack?
I'd say that with the clean redirect to a backend logging system, it
isn't any more of a hack than any other configurable logging facade
system (log4j, slf4j, commons-logging, etc). They're all just facade
systems that run to a back-end logger. We've picked a facade, it's all
in the code, now let's stick to it.
See you all in the GS IRC meeting!
--saul
On Tue, 2007-10-30 at 14:17 -0400, Chris Holmes wrote:
Ok, I'm trying to get a handle on this issue.
One question, what's the objection to just using SFL4J ?
It seems to meet Justin's criteria of using a standard library, it'll
work with sfl4j/jetty (for Andrea), and Martin likes it a lot better
than commons logging.
I imagine I just missed what the objection was, but I'm curious to hear it.
Chris
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________ Geotools-devel mailing list Geotools-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/geotools-devel