How to create an aspect class that will implement the logging functionality. Logged classes/packages/methods need to be defined in the configuration file.
@Aspect
public class LoggingAspect {
private static final Logger log = LoggerFactory.getLogger(LoggingAspect.class);
@Autowired
private List<PackageProperties> packageProperties;
@Pointcut("execution(* org.epam.operations.Operations.removeStudentFromList())")
public void removeStudentLog() {
}
@After("removeStudentLog()")
public void applicationLogger() {
log.info("Student deleted");
}
}
application.properties
remove.packageName = org.epam.operations
remove.className = Operations
remove.methodName = removeStudentFromList
add.packageName = org.epam.operations
add.className = Operations
add.methodName = addStudent