Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] Re: Log4J and Logger.getLogger practices

Stuart:

Facing the same problem I came up with the following solution:

get the Signature from thisJoinPointStaticPart
get from the Signature with getDeclaringType().getName() the name of the class.
Use the className to get your logger.

This works for me but I would be interested if there is a better solution.

Regards,

Andreas




Stuart Quinn wrote:

Good day,

When logging with Log4J without AspectJ I define the logger based on the
class name which allows me to define which classes get logged in my
corresponding Log4J.properties file. Easy, flexible and no recompiles. It
appears if I want to use AspectJ to weave in my logging I can no longer use
this approach since the getLogger method is being performed within the
aspect. I therefore need to define within my pointcut which libraries or
classes I want to log (AspectJ in Action, page 159).

Is there a way to weave in Log4J logging while retaining a logger per class
or per package?

Thanks in advance for your feedback.
Stu


_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/aspectj-users



Back to the top