有没有办法在JHipster中记录静态文件(如index.html或js文件)的请求。
答案 0 :(得分:2)
添加过滤器:
public class RequestLoggingFilter implements Filter {
private static final Logger log = Logger.getLogger(AuditFilter.class);
@Override
public void init(FilterConfig filterConfig) throws ServletException {
}
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
HttpServletRequest httpRequest = (HttpServletRequest) request;
String requestUrl = httpRequest.getRequestURI();
String requestMethod = httpRequest.getMethod();
log.info("Received " + requestMethod + " request + " for " + requestUrl);
chain.doFilter(request, response);
}
@Override
public void destroy() {
}
}