You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by Gary Gregory <ga...@gmail.com> on 2014/01/30 07:24:56 UTC
LOG4J2-301 - Add printf methods to Logger API
I'm slightly confused by this addition because it seems redundant with
using StringFormattedMessage and StringFormattedMessageFactory
Gary
--
E-Mail: garydgregory@gmail.com | ggregory@apache.org
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
Re: LOG4J2-301 - Add printf methods to Logger API
Posted by Remko Popma <re...@gmail.com>.
On Sunday, February 9, 2014, Remko Popma <re...@gmail.com> wrote:
>
>
> Sent from my iPhone
>
> On 2014/02/09, at 1:20, Gary Gregory <garydgregory@gmail.com<javascript:_e(%7B%7D,'cvml','garydgregory@gmail.com');>>
> wrote:
>
> On Sat, Feb 8, 2014 at 12:39 AM, Remko Popma <remko.popma@gmail.com<javascript:_e(%7B%7D,'cvml','remko.popma@gmail.com');>
> > wrote:
>
>> If I remember correctly this was added on request of a user.
>> They did not want to set the StringFormatterMessageFactory when obtaining
>> a Logger because that would force them to use the printf format everywhere.
>> If I remember correctly the use case was that they wanted to use the
>> "message {} with {} params" in most cases but sometimes it was desirable to
>> use the printf format with its more fine-grained control over the output
>> format.
>> Ralph agreed that this would be a useful feature and made the change.
>>
>
> I would not want that in my app... but that's just me.
>
> If the app can say "message {} with {} params" it can say "message %s with
> %s params" just the same IMO.
>
>
> In my app I use the {} format most of the time because it's much faster.
>
Actually it's more than just performance. With the {} format I don't have
to worry about getting a RuntimeException if I pass a double where the
format expects an int/long.
> I think I have a handful of places where I use the printf methods with
> detailed formatting because it's more convenient than creating a new logger
> with StringFormatterMessageFactory just for that message. I would not like
> to have some of my app classes logging with the %s %f format and others log
> with the {} format. That's asking for bugs... :-)
> I also don't want to pay the performance penalty of using the %s format
> everywhere for the handful of cases where I need the detailed formatting.
> So the printf methods serve a useful purpose, I think. Please don't remove
> them.
> -Remko
>
>
> Gary
>
>>
>>
>>
>>
>> On Sat, Feb 8, 2014 at 1:51 PM, Gary Gregory <garydgregory@gmail.com<javascript:_e(%7B%7D,'cvml','garydgregory@gmail.com');>
>> > wrote:
>>
>>> I think it has something to do with making it easier to port call sites
>>> from:
>>>
>>> System.out.println(...)
>>>
>>> and
>>>
>>> Console.printf(...)
>>>
>>> I do not think reusing these API names in Logger is a good idea though.
>>>
>>> I'd like to remove them.
>>>
>>> Gary
>>>
>>>
>>> On Fri, Feb 7, 2014 at 10:18 PM, Nick Williams <
>>> nicholas@nicholaswilliams.net<javascript:_e(%7B%7D,'cvml','nicholas@nicholaswilliams.net');>
>>> > wrote:
>>>
>>>> Yes, I'm confused by this addition to. Why did we do this?
>>>>
>>>> Nick
>>>>
>>>> On Jan 30, 2014, at 12:24 AM, Gary Gregory wrote:
>>>>
>>>> I'm slightly confused by this addition because it seems redundant with
>>>> using StringFormattedMessage and StringFormattedMessageFactory
>>>>
>>>> Gary
>>>>
>>>> --
>>>> E-Mail: garydgregory@gmail.com<javascript:_e(%7B%7D,'cvml','garydgregory@gmail.com');>| ggregory@apache.org
>>>> <javascript:_e(%7B%7D,'cvml','ggregory@apache.org');>
>>>> 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: garydgregory@gmail.com<javascript:_e(%7B%7D,'cvml','garydgregory@gmail.com');>| ggregory@apache.org
>>> <javascript:_e(%7B%7D,'cvml','ggregory@apache.org');>
>>> 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: garydgregory@gmail.com<javascript:_e(%7B%7D,'cvml','garydgregory@gmail.com');>| ggregory@apache.org
> <javascript:_e(%7B%7D,'cvml','ggregory@apache.org');>
> 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
>
>
Re: LOG4J2-301 - Add printf methods to Logger API
Posted by Remko Popma <re...@gmail.com>.
Sent from my iPhone
> On 2014/02/09, at 1:20, Gary Gregory <ga...@gmail.com> wrote:
>
>> On Sat, Feb 8, 2014 at 12:39 AM, Remko Popma <re...@gmail.com> wrote:
>> If I remember correctly this was added on request of a user.
>> They did not want to set the StringFormatterMessageFactory when obtaining a Logger because that would force them to use the printf format everywhere.
>> If I remember correctly the use case was that they wanted to use the "message {} with {} params" in most cases but sometimes it was desirable to use the printf format with its more fine-grained control over the output format.
>> Ralph agreed that this would be a useful feature and made the change.
>
> I would not want that in my app... but that's just me.
>
> If the app can say "message {} with {} params" it can say "message %s with %s params" just the same IMO.
In my app I use the {} format most of the time because it's much faster. I think I have a handful of places where I use the printf methods with detailed formatting because it's more convenient than creating a new logger with StringFormatterMessageFactory just for that message. I would not like to have some of my app classes logging with the %s %f format and others log with the {} format. That's asking for bugs... :-)
I also don't want to pay the performance penalty of using the %s format everywhere for the handful of cases where I need the detailed formatting.
So the printf methods serve a useful purpose, I think. Please don't remove them.
-Remko
> Gary
>>
>>
>>
>>
>>> On Sat, Feb 8, 2014 at 1:51 PM, Gary Gregory <ga...@gmail.com> wrote:
>>> I think it has something to do with making it easier to port call sites from:
>>>
>>> System.out.println(...)
>>>
>>> and
>>>
>>> Console.printf(...)
>>>
>>> I do not think reusing these API names in Logger is a good idea though.
>>>
>>> I'd like to remove them.
>>>
>>> Gary
>>>
>>>
>>>> On Fri, Feb 7, 2014 at 10:18 PM, Nick Williams <ni...@nicholaswilliams.net> wrote:
>>>> Yes, I'm confused by this addition to. Why did we do this?
>>>>
>>>> Nick
>>>>
>>>>> On Jan 30, 2014, at 12:24 AM, Gary Gregory wrote:
>>>>>
>>>>> I'm slightly confused by this addition because it seems redundant with using StringFormattedMessage and StringFormattedMessageFactory
>>>>>
>>>>> Gary
>>>>>
>>>>> --
>>>>> E-Mail: garydgregory@gmail.com | ggregory@apache.org
>>>>> Java Persistence with Hibernate, Second Edition
>>>>> JUnit in Action, Second Edition
>>>>> Spring Batch in Action
>>>>> Blog: http://garygregory.wordpress.com
>>>>> Home: http://garygregory.com/
>>>>> Tweet! http://twitter.com/GaryGregory
>>>
>>>
>>>
>>> --
>>> E-Mail: garydgregory@gmail.com | ggregory@apache.org
>>> Java Persistence with Hibernate, Second Edition
>>> JUnit in Action, Second Edition
>>> Spring Batch in Action
>>> Blog: http://garygregory.wordpress.com
>>> Home: http://garygregory.com/
>>> Tweet! http://twitter.com/GaryGregory
>
>
>
> --
> E-Mail: garydgregory@gmail.com | ggregory@apache.org
> Java Persistence with Hibernate, Second Edition
> JUnit in Action, Second Edition
> Spring Batch in Action
> Blog: http://garygregory.wordpress.com
> Home: http://garygregory.com/
> Tweet! http://twitter.com/GaryGregory
Re: LOG4J2-301 - Add printf methods to Logger API
Posted by Gary Gregory <ga...@gmail.com>.
On Sat, Feb 8, 2014 at 12:39 AM, Remko Popma <re...@gmail.com> wrote:
> If I remember correctly this was added on request of a user.
> They did not want to set the StringFormatterMessageFactory when obtaining
> a Logger because that would force them to use the printf format everywhere.
> If I remember correctly the use case was that they wanted to use the
> "message {} with {} params" in most cases but sometimes it was desirable to
> use the printf format with its more fine-grained control over the output
> format.
> Ralph agreed that this would be a useful feature and made the change.
>
I would not want that in my app... but that's just me.
If the app can say "message {} with {} params" it can say "message %s with
%s params" just the same IMO.
Gary
>
>
>
>
> On Sat, Feb 8, 2014 at 1:51 PM, Gary Gregory <ga...@gmail.com>wrote:
>
>> I think it has something to do with making it easier to port call sites
>> from:
>>
>> System.out.println(...)
>>
>> and
>>
>> Console.printf(...)
>>
>> I do not think reusing these API names in Logger is a good idea though.
>>
>> I'd like to remove them.
>>
>> Gary
>>
>>
>> On Fri, Feb 7, 2014 at 10:18 PM, Nick Williams <
>> nicholas@nicholaswilliams.net> wrote:
>>
>>> Yes, I'm confused by this addition to. Why did we do this?
>>>
>>> Nick
>>>
>>> On Jan 30, 2014, at 12:24 AM, Gary Gregory wrote:
>>>
>>> I'm slightly confused by this addition because it seems redundant with
>>> using StringFormattedMessage and StringFormattedMessageFactory
>>>
>>> Gary
>>>
>>> --
>>> E-Mail: garydgregory@gmail.com | ggregory@apache.org
>>> 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: garydgregory@gmail.com | ggregory@apache.org
>> 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: garydgregory@gmail.com | ggregory@apache.org
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
Re: LOG4J2-301 - Add printf methods to Logger API
Posted by Remko Popma <re...@gmail.com>.
If I remember correctly this was added on request of a user.
They did not want to set the StringFormatterMessageFactory when obtaining a
Logger because that would force them to use the printf format everywhere.
If I remember correctly the use case was that they wanted to use the
"message {} with {} params" in most cases but sometimes it was desirable to
use the printf format with its more fine-grained control over the output
format.
Ralph agreed that this would be a useful feature and made the change.
On Sat, Feb 8, 2014 at 1:51 PM, Gary Gregory <ga...@gmail.com> wrote:
> I think it has something to do with making it easier to port call sites
> from:
>
> System.out.println(...)
>
> and
>
> Console.printf(...)
>
> I do not think reusing these API names in Logger is a good idea though.
>
> I'd like to remove them.
>
> Gary
>
>
> On Fri, Feb 7, 2014 at 10:18 PM, Nick Williams <
> nicholas@nicholaswilliams.net> wrote:
>
>> Yes, I'm confused by this addition to. Why did we do this?
>>
>> Nick
>>
>> On Jan 30, 2014, at 12:24 AM, Gary Gregory wrote:
>>
>> I'm slightly confused by this addition because it seems redundant with
>> using StringFormattedMessage and StringFormattedMessageFactory
>>
>> Gary
>>
>> --
>> E-Mail: garydgregory@gmail.com | ggregory@apache.org
>> 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: garydgregory@gmail.com | ggregory@apache.org
> 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
>
Re: LOG4J2-301 - Add printf methods to Logger API
Posted by Gary Gregory <ga...@gmail.com>.
I think it has something to do with making it easier to port call sites
from:
System.out.println(...)
and
Console.printf(...)
I do not think reusing these API names in Logger is a good idea though.
I'd like to remove them.
Gary
On Fri, Feb 7, 2014 at 10:18 PM, Nick Williams <
nicholas@nicholaswilliams.net> wrote:
> Yes, I'm confused by this addition to. Why did we do this?
>
> Nick
>
> On Jan 30, 2014, at 12:24 AM, Gary Gregory wrote:
>
> I'm slightly confused by this addition because it seems redundant with
> using StringFormattedMessage and StringFormattedMessageFactory
>
> Gary
>
> --
> E-Mail: garydgregory@gmail.com | ggregory@apache.org
> 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: garydgregory@gmail.com | ggregory@apache.org
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
Re: LOG4J2-301 - Add printf methods to Logger API
Posted by Nick Williams <ni...@nicholaswilliams.net>.
Yes, I'm confused by this addition to. Why did we do this?
Nick
On Jan 30, 2014, at 12:24 AM, Gary Gregory wrote:
> I'm slightly confused by this addition because it seems redundant with using StringFormattedMessage and StringFormattedMessageFactory
>
> Gary
>
> --
> E-Mail: garydgregory@gmail.com | ggregory@apache.org
> Java Persistence with Hibernate, Second Edition
> JUnit in Action, Second Edition
> Spring Batch in Action
> Blog: http://garygregory.wordpress.com
> Home: http://garygregory.com/
> Tweet! http://twitter.com/GaryGregory