Agree but doesn't the current code use the classpath order? If not, could
it? That would be deterministic, just like I can place a jar at the front
of the CP to override one or more classes.

Gary

On Fri, Sep 28, 2012 at 3:51 PM, Ralph Goers <ralph.go...@dslextreme.com>wrote:

> The problem I have is that it isn't deterministic and I very much dislike
> that.  SLF4J is that way today and it is annoying that you can't guarantee
> the winner.
>
> Ralph
>
>
>
> On Sep 28, 2012, at 11:21 AM, Gary Gregory wrote:
>
> What about just picking the first one like in the example below (note the
> new error message)
>
> Gary
>
> On Sep 28, 2012, at 14:06, Ralph Goers <ralph.go...@dslextreme.com> wrote:
>
> That is interesting.  So Eclipse is seeing both the API's test factory and
> the real implementation.  I guess that makes sense.  I would probably have
> the same problem in IntelliJ except that I never run tests for anything in
> my IDE but always run Maven from the command line - even to debug.
>
> At one point I considered allowing multiple implementations, but passing
> events to two logging implementations seems like a performance nightmare.
>  Also, the Log4j 2 API isn't really intended as a competitor or replacement
> for SLF4J.
>
> I think a better way to do this is to add one more piece of information to
> the meta-data - a rank/weight as is being done with the configuration
> factory. Then we will pick the one with the highest rank.
>
> Ralph
>
> On Sep 28, 2012, at 10:51 AM, Gary Gregory wrote:
>
> Hi All,
>
> I am using Eclipse as my IDE and when I run
> org.apache.logging.log4j.core.BasicLoggingTest I get an NPE because
> org.apache.logging.log4j.LogManager.factory is null. It is null because
> when the static initializer runs it picks up 2 factories instead of one:
>
> [org.apache.logging.log4j.core.impl.Log4jContextFactory@39c8c1,
> org.apache.logging.log4j.SimpleLoggerContextFactory@1ab2b55].
>
> Can we be more lenient?
>
> Instead of:
>
>             if (factories.size() != 1) {
>                 logger.fatal("Unable to locate a logging implementation");
>             } else {
>                 factory = factories.get(0);
>             }
>
> How about:
>
>             if (factories.size() != 1) {
>                 logger.error("Expected a single logging implementation,
> not {}, picking the first: {}", factories.size(), factories.get(0));
>             }
>             factory = factories.get(0);
>
> ?
>
> --
> E-Mail: garydgreg...@gmail.com | ggreg...@apache.org
> JUnit in Action, 2nd Ed: <http://goog_1249600977/>http://bit.ly/ECvg0
> Spring Batch in Action: <http://s.apache.org/HOq>http://bit.ly/bqpbCK
> Blog: http://garygregory.wordpress.com
> Home: http://garygregory.com/
> Tweet! http://twitter.com/GaryGregory
>
>
>
>


-- 
E-Mail: garydgreg...@gmail.com | ggreg...@apache.org
JUnit in Action, 2nd Ed: <http://goog_1249600977>http://bit.ly/ECvg0
Spring Batch in Action: <http://s.apache.org/HOq>http://bit.ly/bqpbCK
Blog: http://garygregory.wordpress.com
Home: http://garygregory.com/
Tweet! http://twitter.com/GaryGregory

Reply via email to