On Mon, Jun 20, 2011 at 12:07:09PM +0000, [email protected] wrote:
> https://defect.opensolaris.org/bz/show_bug.cgi?id=18585
>
> Knut Anders Hatlen <[email protected]> changed:
>
> What |Removed |Added
> ----------------------------------------------------------------------------
> Status|ACCEPTED |CLOSED
> Resolution| |FIXED
> Target Milestone|--- |next
>
> --- Comment #1 from Knut Anders Hatlen <[email protected]> 2011-06-20
> 12:07:08 UTC ---
> changeset: 1258:b889068b5d93
Hmmm, well, actually the intention was to silent logs, i.e. print
stacktraces only, when debugging for this class is enabled. So the
"correct" way would be:
if (null != thrown &&
Logger.getLogger(record.getLoggerName()).getLevel().intValue() >
Level.CONFIG.intValue())
{
...
}
I call that, from the back through the breast ;-), since the method
which calls "format(...)" already knows, what gets accomplished "brute
force like" with Logger.getLogger...
Anyway:
To get Logging correct, in general the pattern one should always use is:
class Foo ... {
static final Logger log = Logger.getLogger(Foo.class.getName());
try {
...
} catch (*Exception e) {
log.warn(e.getLocalizedMessage();
if (log.isDebugEnabled()) {
log.debug("$hint-e-g-methodName", e);
}
}
}
So yes, "Logger logger = OpenGrokLogger.getLogger(); log..." is plain
wrong. In addition, OpenGrokLogger hard codes pretty everything, which
makes logging almost useless.
IMHO, we should switch over to use slf4j (see slf4j.org) and than
everybody can use the logging framework he like and make use of its
features. Also this way, OpenGrokLogger and *Formatter can be phased out
(i.e. removed) completely and actually _should be_.
Would that be a problem: Nope. Tomcats already use slf4j, glassfish comes
with an adapter and for standalone usage, slf4j comes with adapters
(i.e. implementation wrappers) for jul, apach.commons.logging, log4j etc.
Finally, I would ship opengrok with a native implementation named logback
(see http://logback.qos.ch/): here one is able to get all the functionallity
OpenGrokLogger is trying to deliver, but in a much more flexible way
just by supplying an appropriate logback.xml file ...
What do you think?
Regards,
jel.
--
Otto-von-Guericke University http://www.cs.uni-magdeburg.de/
Department of Computer Science Geb. 29 R 027, Universitaetsplatz 2
39106 Magdeburg, Germany Tel: +49 391 67 12768
_______________________________________________
opengrok-dev mailing list
[email protected]
http://mail.opensolaris.org/mailman/listinfo/opengrok-dev