[slf4j-user] RFC: slf4j-fluent
niels
opensource21 at gmail.com
Fri Feb 15 21:07:59 CET 2019
See the message from Ceki
"
Hello Niels,
I am following up on our discussion on stackoverflow.
Since logback-classic exposes its API via SLF4J, you would probably
want to extend org.slf4j.Logger. See the org.slf4j.ext package for
extension examples. The org.slf4j.ext.LoggerWrapper [1] class should
be particularly helpful. See also XLogger [2] and XLoggerFactory [3]
in the same package. The key here is to invoke LocationAwareLogger
when you can, i.e. when one of log4j, jul and logback is the
backend. That is as easy as:
class X {
private static final String FQCN = X.class.getName();
protected final boolean instanceofLAL;
X() {
if (logger instanceof LocationAwareLogger) {
instanceofLAL = true;
} else {
instanceofLAL = false;
}
}
void debug(Throwable t, String msg, ....) {
if (instanceofLAL) {
((LocationAwareLogger) logger).log(null, FQCN ,
LocationAwareLogger.TRACE_INT, msg, null, t);
} else {
logger.trace(msg, t);
}
}
"
It was years ago that I played around with it, so don't remember the
details, but I think this should be a possible way.
Niels
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.qos.ch/pipermail/slf4j-user/attachments/20190215/632b2fdd/attachment.html>
More information about the slf4j-user
mailing list