logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gary Gregory <garydgreg...@gmail.com>
Subject Re: [LOG4J2-133] part 2: LogManager API
Date Sat, 08 Dec 2012 02:40:28 GMT
Thank you for the feedback.

I committed the LogManager changes and fixed the bug you found where the
message factory was not propagated in the simple logger context class.

TODO: Update the manual and add more tests to the core logger and to verify
that we log warnings to the status logger.

Thank you,
Gary


On Fri, Dec 7, 2012 at 5:51 PM, Ralph Goers <ralph.goers@dslextreme.com>wrote:

> Calling getLogger() with a MessageFactory that is different than the one
> already attached to the Logger should at least generate a warning in the
> StatusLogger as it is going to mean that anything using that Logger
> instance variable is not going to be formatted properly. However, if the
> call is to getLogger() without a MessageFactory then we should assume the
> caller knows which MessageFactory is being used.
>
> You should document this in the javadoc and the manual.  It probably
> deserves a mention both in the API doc where Messages are discussed as well
> as in the Architecture page where Loggers are discussed.
>
> Ralph
>
> On Dec 7, 2012, at 2:21 PM, Gary Gregory wrote:
>
> I've attached to LOG4J2-133 a part 2 diff file.
>
> This gives us a way to pass a MessageFactory to new
> getLogger(String|Class|Object, MessageFactory) APIs.
>
> For example:
>
>         TestLogger testLogger = (TestLogger)
> LogManager.getLogger(TestStringFormatterMessageFactory.class,
>                 new StringFormatterMessageFactory());
>         assertNotNull(testLogger);
>         testLogger.debug("%,d", Integer.MAX_VALUE);
>         assertEquals(1, testLogger.getEntries().size());
>         assertEquals(String.format(" DEBUG %,d", Integer.MAX_VALUE),
> testLogger.getEntries().get(0));
>
> When you call getLogger(String|Class|Object), you get a Logger back, if
> there is not one, it is created.
>
> Now we have new APIs with a MessageFactory parameter. This parameter is
> only used when creating the logger, which means it is only used the first
> time the API is called.
>
> If you subsequently call getLogger for the same logger, the MessageFactory
> is ignored.
>
> When the Logger is created, the MessageFactory is saved in a final ivar
> field.
>
> I did not document this in the API yet but I plan on doing so.
>
> Does anyone see a better way than documentation to deal with this?
>
> Should a warning be logged if you call getLogger with a message factory
> that is different than the one already set?
>
> Thank you,
> Gary
>
> --
> E-Mail: garydgregory@gmail.com | ggregory@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: garydgregory@gmail.com | ggregory@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

Mime
View raw message