Closed GoogleCodeExporter closed 9 years ago
1) If we're going to make this, I propose to extend @Log4j2 to get an extra
parameter:
boolean formatted() default false;
2) We're not going to have the name of the method a String
3) I don't see how this removes the "code drudgery if(log.isDebugEnabled())
transparently". As far as I can see, it only allows java string formatting
instead of only used toString for object parameters.
4) We're working at a different approach where lombok will insert if-statements
automagically for log statements. The only downside is that you are limited to
a single line to generate your log message.
Original comment by r.spilker
on 2 Sep 2013 at 8:10
Also, in most cases the toString is just fine, or you can easily replace the
toString with a single value. It is only logging, so as long as the data is in
there, it's fine. For all other cases: it's not boilerplate anymore.
Original comment by r.spilker
on 2 Sep 2013 at 8:13
Hey
I was reading basically;
a) http://logging.apache.org/log4j/2.x/manual/api.html and
b) http://logging.apache.org/log4j/2.x/performance.html
where it conveys a statement that
"The best approach to avoid the cost of parameter construction is to use Log4j
2's formatting capabilities. For example, instead of the above write:"
logger.debug("Entry number: {} is {}", i, entry[i]);
So anyways; as long as i get LogManager.getFormatterLogger() i am good and it
helps.
Original comment by venkates...@gmail.com
on 2 Sep 2013 at 3:10
> Also, in most cases the toString is just fine, or you can easily replace the
toString with a single value. It is only logging, so as long as the data is in
there, it's fine. For all other cases: it's not boilerplate anymore.
I don't think so: I don't remember having seen anything like `logger.info(o)`,
it was always something like `logger.info("initial value of o is " + o)`, which
is rather costly in case of logging disabled.
> 3) I don't see how this removes the "code drudgery if(log.isDebugEnabled())
transparently". As far as I can see, it only allows java string formatting
instead of only used toString for object parameters.
It allows you to leave the if-statement out:
http://www.slf4j.org/faq.html#logging_performance
> 4) We're working at a different approach where lombok will insert
if-statements automagically for log statements.
Nice!
Original comment by Maaarti...@gmail.com
on 6 Sep 2013 at 12:44
If I understood correctly, you can already do
log.info("initial value of o us {}", o);
Where the {} is replaced by the toString of o only if the level is set to info
or lower.
So my point is that in all cases, {} in the default logger is the same as %s in
the formatted logger. The only difference is that with {} you always get the
toString. There might be some cases where you want to do better logging. But I
think those are either rare, or won't be solved using the formatted logger
anyway.
And yes, I am pretty sure you can come up with some cases where it makes a
difference. But I think that those are not boilerplate, or common enough.
That said, I can imagine having the extra parameters in @Log4j2.
Original comment by r.spilker
on 6 Sep 2013 at 10:38
To make it absolutely clear:
With the current lombok-generated code, you can already use {} for parameter
substitution. The only thing the getFormatterLogger provides is to use a
different syntax, the syntax from java.util.Formatter, allowing for a bit more
control over the rendering of the values.
Original comment by r.spilker
on 6 Sep 2013 at 10:40
Absolute it still relative :-)
You don't need getFormatterLogger to use {}. More strongly: getFormatterLogger
does not support the {} syntax.
Original comment by r.spilker
on 6 Sep 2013 at 10:42
So can this still be considered for adding.
Original comment by venkates...@gmail.com
on 22 Nov 2013 at 5:42
Sorry, not really boilerplate and too little value for money. We've got loads
of other stuff to do.
Original comment by r.spilker
on 23 Jan 2014 at 7:06
Original issue reported on code.google.com by
venkates...@gmail.com
on 1 Sep 2013 at 8:00