[slf4j-user] Should NOPLogger implement org.slf4j.spi.LocationAwareLogger? Dealing with appender startup problem
Seth Call
sethcall at gmail.com
Mon Feb 22 16:12:31 CET 2010
Hi Ceki,
The method in question is this:
public void log(String FQCN, Priority p, Object msg, Throwable t) {
int levelInt = priorityToLevelInt(p);
if (locationAwareLogger != null) {
locationAwareLogger.log(null, FQCN, levelInt,
convertToString(msg), t);
} else {
throw new UnsupportedOperationException("The logger [" + slf4jLogger
+ "] does not seem to be location aware.");
}
}
You are right: I only saw this when the logger was the NOPLogger. I saw
the UnsupportedOperationException shown in that method was thrown.
What I'm suggesting is that the NOPLogger should implement
LocationAwareLogger, since I don't see any value in having the NOPLogger
stop a log from happening...
Thanks,
Seth
On 2/22/10 12:45 AM, Ceki Gulcu wrote:
> Hello Seth,
>
>
> Reading the code of the Category class in log4j-over-slf4j, it appears
> that both loggers of type org.slf4j.Logger *and* LocationAwareLogger
> are supported. Category class in log4j-over-slf4j should throw an
> exception if the slf4j logger it gets is of type NOPLogger. Can you
> show the exception you are observing?
>
> Cheers,
>
> On 22.02.2010 01:57, ownedthx wrote:
>>
>> Hi all,
>>
>> I'm using a logback appender which logs during startup, causing a
>> NOPLogger
>> to be created while the underlying library initializes.
>>
>> In this specific scenario, I'm coercing a 3rd-party library out of
>> direct
>> log4j usage by using the log4j-over-slf4j bridge. However, the
>> Category.java implementation in the bridge will throw an exception if
>> the
>> underlying logger (in this case, NOPLogger) does not implement the
>> LocationAwareLogger interface.
>>
>> This seems wrong to me--seems to me the NOPLogger should implement
>> LocationAwareLogger, and NOP the log statement specific to that, just
>> like
>> it does with all the other various log overloads it implements,
>> instead of
>> causing the appender to fail to start.
>>
>> Any thoughts on this?
>>
>> By the way, I did stop the error by doing just what was recommended
>> here...
>>
>> Thanks,
>> Seth
>>
>>
>
> _______________________________________________
> slf4j-user mailing list
> slf4j-user at qos.ch
> http://qos.ch/mailman/listinfo/slf4j-user
More information about the slf4j-user
mailing list