Matt and all:

Please review *log4j-streams *in master.

The current nasty is this the required type cast to *ExtendedLogger*:

java.sql.DriverManager.setLogWriter(new LoggerPrintWriter((*ExtendedLogger*)
LogManager.getLogger(), Level.DEBUG));

Internally, *LogManager.getLogger()* uses an *ExtendedLogger* but upcasts
it to a plain *Logger*, for no good technical reason (see below).

Specifically:

    public static Logger getLogger(final String name) {
        final String actualName = name != null ? name : getClassName(2);
        return factory.getContext(LogManager.class.getName(), null, null,
false).getLogger(actualName);
    }

Where *getLogger() *is:

org.apache.logging.log4j.spi.LoggerContext.getLogger(String)

The only reason I've heard on the ML to upcast from *ExtendedLogger* to
*Logger* is to hide the extra method from users. This now seems like
jumping through hoops for not much effect.

We cannot downcast the public API without breaking BC.

I see the following options:

- Do nothing and force call sites to downcast (good enough today).
- Add *ExtendedLogger* version of methods to *LogManager*.
- Create a parallel class to *LogManager *called *ExtendedLogManger *that
only deals *ExtendedLogger*s

*.*
Thoughts?

Gary




On Tue, Sep 2, 2014 at 8:11 PM, Gary Gregory <[email protected]> wrote:

> I'm almost done, I'll commit, please review...
>
> Gary
>
>
> On Tue, Sep 2, 2014 at 7:53 PM, Matt Sicker <[email protected]> wrote:
>
>> Yeah I think I can take care of that tonight.
>>
>>
>> On 2 September 2014 14:41, Gary Gregory <[email protected]> wrote:
>>
>>> Matt,
>>>
>>> Do you have time for that today?
>>>
>>> Gary
>>>
>>>
>>> -------- Original message --------
>>> From: Matt Sicker
>>> Date:09/02/2014 14:20 (GMT-05:00)
>>> To: Log4J Developers List
>>> Subject: Re: log4j-streams and ExtendedLoggers
>>>
>>> Yeah I think that'd be a good idea.
>>>
>>>
>>> On 2 September 2014 09:49, Gary Gregory <[email protected]> wrote:
>>>
>>>> So... should retype all of the methods that cast to ExtendedLogger and
>>>> in turn their call sites?
>>>>
>>>> Gary
>>>>
>>>>
>>>> On Tue, Sep 2, 2014 at 10:22 AM, Matt Sicker <[email protected]> wrote:
>>>>
>>>>> This was written before all that was done. I had to rename it from
>>>>> LoggerProvider to ExtendedLogger even!
>>>>>
>>>>>
>>>>> On 2 September 2014 09:21, Gary Gregory <[email protected]>
>>>>> wrote:
>>>>>
>>>>>> Some of the streams API take a org.apache.logging.log4j.Logger and
>>>>>> cast it to an org.apache.logging.log4j.spi.ExtendedLogger.
>>>>>>
>>>>>> Why not just type to an ExtendedLoggers?
>>>>>>
>>>>>> Gary
>>>>>>
>>>>>> --
>>>>>> E-Mail: [email protected] | [email protected]
>>>>>> Java Persistence with Hibernate, Second Edition
>>>>>> <http://www.manning.com/bauer3/>
>>>>>> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
>>>>>> Spring Batch in Action <http://www.manning.com/templier/>
>>>>>> Blog: http://garygregory.wordpress.com
>>>>>> Home: http://garygregory.com/
>>>>>> Tweet! http://twitter.com/GaryGregory
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Matt Sicker <[email protected]>
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> E-Mail: [email protected] | [email protected]
>>>> Java Persistence with Hibernate, Second Edition
>>>> <http://www.manning.com/bauer3/>
>>>> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
>>>> Spring Batch in Action <http://www.manning.com/templier/>
>>>> Blog: http://garygregory.wordpress.com
>>>> Home: http://garygregory.com/
>>>> Tweet! http://twitter.com/GaryGregory
>>>>
>>>
>>>
>>>
>>> --
>>> Matt Sicker <[email protected]>
>>>
>>
>>
>>
>> --
>> Matt Sicker <[email protected]>
>>
>
>
>
> --
> E-Mail: [email protected] | [email protected]
> Java Persistence with Hibernate, Second Edition
> <http://www.manning.com/bauer3/>
> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
> Spring Batch in Action <http://www.manning.com/templier/>
> Blog: http://garygregory.wordpress.com
> Home: http://garygregory.com/
> Tweet! http://twitter.com/GaryGregory
>



-- 
E-Mail: [email protected] | [email protected]
Java Persistence with Hibernate, Second Edition
<http://www.manning.com/bauer3/>
JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
Spring Batch in Action <http://www.manning.com/templier/>
Blog: http://garygregory.wordpress.com
Home: http://garygregory.com/
Tweet! http://twitter.com/GaryGregory

Reply via email to