Hi Malte. So you want to use AspectJ for logging, but you do not want to depend on the AspectJ runtime? This is kind of a contradiction, assuming that logging is a production aspect, not just a development aspect. ;-)
Please explain your problem more clearly. Is your intention to do some logging from within aspects and some in your core code, both using the same Logger instance? And is your logger identified by something else than the class name? Alexander Kriegisch Am 12.02.2013 um 16:11 schrieb "Kempff, Malte" <[email protected]>: > Hi to all, > I am pretty new to AspectJ and was wondering about a thing… > I saw some nice examples like logging methods the start and the end. In that > example there was just an System.out used. I was trying that using log4j but > did not get along directly. > After some googling I found a kind of reflective workaround so it looks like > this; > import org.apache.log4j.Logger; > import org.aspectj.lang.Signature; > import de.lala.Klasse1 > import de.lala.Klasse2; > import de.lala.Klasse3; > public aspect Performance > { > > pointcut classes() : within(Klasse1) || within (Klasse2) || > within(Klasse3); > pointcut constructors() : classes() && execution(new(..)); > pointcut methods() : classes() && execution (* *(..)); > > > before () : constructors() || methods() > { > Signature sig = thisJoinPointStaticPart.getSignature(); > Logger logger = Logger.getLogger(sig.getDeclaringType()); > logger.info("----- start:"+sig); > } > > after () : constructors() || methods() > { > Signature sig = thisJoinPointStaticPart.getSignature(); > Logger logger = Logger.getLogger(sig.getDeclaringType()); > logger.info("----- end:"+sig); > } > } > > The disadvantage is that I need the aspect-library to run my program. > Is there any way to use the static logger field provided in eaqch class of > its own for the advice? If yes, what is the correct syntax for that? > > Thanks for useful hints in advance > > Malte > ------------------------------------------------------------------------------------------------ > Disclaimer: The contents of this electronic mail message are only binding > upon Equens or its affiliates, if the contents of the message are accompanied > by a lawfully recognised type of signature. The contents of this electronic > mail message are privileged and confidential and are intended only for use by > the addressee. If you have received this electronic mail message by error, > please notify the sender and delete the message without taking notices of its > content, reproducing it and using it in any way. > ------------------------------------------------------------------------------------------------ > _______________________________________________ > aspectj-users mailing list > [email protected] > https://dev.eclipse.org/mailman/listinfo/aspectj-users
_______________________________________________ aspectj-users mailing list [email protected] https://dev.eclipse.org/mailman/listinfo/aspectj-users
