问题描述
我们正在做一些性能测试,以确定应用程序的哪些步骤需要花费多少时间.当然,使用regexp易于解析/过滤日志是一种魅力.问题所在:我们的jsf应用程序分为几个项目,供其他(非jsf)应用程序使用.我的第一种方法是:
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将从HttpServletRequest中读取sessionId)
(CookieUtil would read the sessionId from the HttpServletRequest)
但是...显然,其他项目不喜欢对JSF库的依赖,也不喜欢我整洁的CookieUtil.log4j是否提供某些东西?为此还有其他工具/概念吗?
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?
推荐答案
您可以完成需要使用log4j MDC进行的查找: Log4j MDC
You could accomplish what you are looking for w/ log4j MDC:Log4j MDC
,并使用类似于此示例的Servlet过滤器: MDCServletFilter
and using a Servlet Filter similar to this example:MDCServletFilter
这篇关于在每个级别的日志中,每个用户/会话的唯一ID? Log4J?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!