On Tue, Sep 25, 2012 at 11:03 AM, Ralph Goers <ralph.go...@dslextreme.com>wrote:

> Can you look at the context of where you like to write
> logger.error(Throwable) and see if it is at all possible to do something
> with annotations there?  For example, in a catch statement could you do
>
> catch (@log  UnsupportedOperationException ex)
>
> This kind of use of annotations is something I've thought about and why I
> created LOG4J2-33.
>

I love it!

This is the kind of innovation I should have in 2.0!

My tweaks for 2.0 would be to change: Log.get() to Logger.get() because you
are getting a Logger instance.

My additional tweak would be to allow for per-instance Loggers. For finer
grained control of massive logging output, our users can control logging of
components based on their names.

For example:

new MyComponent("name")

where the ctor does:

MyComponent(String name) {
   this.logger = Logger.getLogger(MyComponent.class.getName() + "." + name;
   this.name = name;
}

How would that work with annotations? I guess it cannot :( I could say:

@Loggable(instance=true)
MyComponent(String name) {
   Logger.get().setName(MyComponent.class.getName() + "." + name)
   // or: avoid a class ref w:
   Logger.get().appendName("." + name)
   this.name = name;
}

?

Gary




> Ralph
>
> On Sep 24, 2012, at 7:50 PM, Gary Gregory wrote:
>
> The issue is closed so I'll comment here.
>
> Over all, my port to 2.0 went well, aside from some 1.2 compat issue I
> JIRA'd.
>
> Let's make a difference between binary compat and source compat. BC is no
> problem, calling error(), info(), and so on with a Throwable is the same as
> with 1.2.
>
> For SC, since you are recompiling, IMO, it is OK for a MAJOR release to be
> different and print the stack trace.
>
> It is just so nice to say debug(Throwable) and have the right thing (IMO
> again) happen.
>
> Having code say debug(throwable.toString(), throwable) is just... well
> lame :(
>
> The catching/throwing methods are so horribly named -- despite whatever
> history of inheriting genes from other logging frameworks -- that I shiver
> at the thought of using them. I had to read the Javadocs /carefully/. No
> big deal, I'll just ignore them. Then I am immediately wondering how these
> goofy APIs fit in with the other nicely named ones, error, warn, and so on.
> It's baffling to me. Must be my tired brain and body, I just moved ;)
>
> Gary
>
> On Mon, Sep 24, 2012 at 8:38 PM, Ralph Goers 
> <ralph.go...@dslextreme.com>wrote:
>
>> See Log4j2-86 and Paul's concerns.
>>
>> Ralph
>>
>> On Sep 24, 2012, at 4:38 PM, Gary Gregory wrote:
>>
>> Hi All,
>>
>> Most of the time, I now do:
>>
>>    logger.error(throwable.toString(), throwable);
>>
>> I do this instead of
>>
>>    logger.error(throwable.getMessage(), throwable)
>>
>> in case the message is null.
>>
>> But I'd rather simply say:
>>
>>    logger.error(throwable)
>>
>> Same idea for other levels.
>>
>> Thoughts?
>>
>> Gary
>>
>> --
>> 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
>
>
>


-- 
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