How to add jsession id in apache http access log

I need to make access logs for my web application. We use the appache http server before jboss.i I use the Apache access directive for this, but the problem is that there is no directive to get the sessionid in the access log. I need sessionid in the access logs for statistics report.pls, who has a solution, help me.

+5
source share
2 answers

If your web application always uses cookies to manage sessions, everything will be alright with changing your LogFormat and adding an option to register a specific cookie:

LogFormat ... \"%{JSESSIONID}C\" ... combined

, . : http://httpd.apache.org/docs/2.2/mod/mod_log_config.html#formats:

% {Foobar}

cookie Foobar , . cookie 0.

jsessionid, evene, url, - (, tomcat) :

response.setHeader("X-JSESSIONID", request.getSession().getId());

Apache RepsonseHeader

% {Foobar}

Foobar: .

- :

LogFormat ... \"%{X-JSESSIONID}o\" ... combined

. jsessionid, , , . tomcat, , sessionid.

String sessionId = request.getSession().getId();
String crypt = yourcryptalgo(sessionId);
response.setHeader("X-JSESSIONID", crypt);
+11

% {JSESSIONID} C LogFormat

+1

All Articles