// @元器件 公共类MyAppender扩展了AppenderSkeleton {
@Override
protected void append(LoggingEvent event) {
System.out.println("Peform Sending sns task here ........");
try {
//Send to Sns or any other source
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println("done sleeping");
}
static{
System.out.println("Loading MyAppender Class");
}
@Override
public void close() {
// TODO Auto-generated method stub
}
@Override
public boolean requiresLayout() {
// TODO Auto-generated method stub
return false;
}
} // EOF MyAppender
公共类LoggingFilter扩展了OncePerRequestFilter {
@Override
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response,
final FilterChain filterChain) throws ServletException, IOException {
filterChain.doFilter(request, response);
System.out.println("Logging is Started From Filters >>>>>>>>>>>");
logger.debug("This is my test Log Msg 1");
logger.debug("This is my test Log Msg 2");
logger.debug("This is my test Log Msg 3");
logger.debug("This is my test Log Msg 4");
logger.debug("This is my test Log Msg 5");
System.out.println("Logging is Completed in Filters >>>>>>>>>>>");
} }
期望输出: 记录从过滤器开始 记录从过滤器
完成在外部完成其他事情,但我的流程是顺序的