Wildfly 14.0 with Aspectj

96 Views Asked by At

I'm want to use Aspectj in project. I created helloworld basic servlet project. When I deploy my project on Wildfly 14, I don't see any logs on Wilfly 14.0 console from MyAspect class. I am not sure about to add anything my code or Wildfly 14.0. Here my classes,

MyAspect

@Aspect
public class MyAspect {

    static Logger logger = Logger.getLogger("MyAspect");

    @Before("execution(* org.jboss.as.quickstarts.helloworld.HelloService.*(..))")
    public void testModeOnlyMethods() {
        logger.info("AspectLog");
    }
} 

HelloWorldServlet

public class HelloWorldServlet extends HttpServlet {

    static String PAGE_HEADER = "<html><head><title>helloworld</title></head><body>";

    static String PAGE_FOOTER = "</body></html>";

    @Inject
    HelloService helloService;

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        resp.setContentType("text/html");
        PrintWriter writer = resp.getWriter();
        writer.println(PAGE_HEADER);
        writer.println("<h1>" + helloService.createHelloMessage("World") + "</h1>");
        writer.println(PAGE_FOOTER);
        writer.close();
    }

}

HelloService

public class HelloService {

    static Logger logger = Logger.getLogger("HelloService");

    String createHelloMessage(String name) {
        logger.info("Aspect");
        return "Hello " + name + "!";
    }
}

Project Structure

enter image description here

0

There are 0 best solutions below