public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException {
LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
ContextSelector selector = ContextSelectorStaticBinder.getSingleton().getContextSelector();
ContextJNDISelector sel = null;
if (selector instanceof ContextJNDISelector) {
sel = (ContextJNDISelector)selector;
sel.setLocalContext(lc);
}
try {
chain.doFilter(request, response);
} finally {
if (sel != null) {
sel.removeLocalContext();
}
}
}