问题描述
好吧,我们正在进行一些性能测试,以找出应用程序的哪些步骤需要多少时间.当然,用RegexP易于解析/过滤器日志是一种魅力. 问题:我们的JSF应用程序分为几个项目,这些项目被其他(非JSF)应用程序使用. 我的第一种方法是:
if(logger.isDebugEnabled()) logger.debug("Service call took: " + (System.currentTimeMillis() - time)+ " JSESSIONID="+CookieUtil.getJsessionId(FacesContext.getCurrentInstance())) ;
(cookieutil将从httpservletrequest读取sessionID)
但是...显然其他项目不喜欢JSF库的依赖性,也不喜欢我整洁的cookieutil. log4j是否提供东西? 有另一个工具/概念吗?
推荐答案
您可以完成您正在寻找的W/log4j MDC: log4j mdc
并使用类似于此示例类似的servlet过滤器: mdcservletfilter
问题描述
Well we are doing some performance testing to figure out what steps of our application take how much time. Of course easy to parse / filter logs with regexp are a charm. To the problem: Our jsf application is split into several projects, which are used by other (non jsf) applications. My first approach would have been:
if(logger.isDebugEnabled()) logger.debug("Service call took: " + (System.currentTimeMillis() - time)+ " JSESSIONID="+CookieUtil.getJsessionId(FacesContext.getCurrentInstance())) ;
(CookieUtil would read the sessionId from the HttpServletRequest)
But... obviously other projects don't like dependencies to JSF libraries, nor to my neat CookieUtil. Does log4j provide something? Is there another tool / concept for this?
推荐答案
You could accomplish what you are looking for w/ log4j MDC: Log4j MDC
and using a Servlet Filter similar to this example: MDCServletFilter