You can use aspectj without Spring (or log4j) to log messages in any aspect of the supported connection points,
For example,
public aspect ListAllMethodExecution { private int callDepth; private pointcut executionJoinPoints(): !within(ListAllMethodExecution) && execution (* *.*(..)); before(): executionJoinPoints(){ print("Before call " + thisJoinPoint); callDepth++; } after(): executionJoinPoints(){ callDepth--; print("After call " + thisJoinPoint); } private void print(String s){ for(int i=0; i<callDepth; i++) System.out.print(" "); System.out.println(s); } }
You can modify the pointcut expression to register specific events or other static connection points that may interest you from specific packages. You can also change the printing method as you want to redirect logs.
You can use the download time or compile the time suitable for you. Hope this helps.
rsingh25
source share