logging - How to get value from a map stored on a httpsession when running on Tomcat -
with tomcat, possible dump pile of interesting information logfile configuring appropriate valve.
for example:
<valve classname="org.apache.catalina.valves.accesslogvalve" directory="logs" prefix="localhost." suffix=".txt" pattern='%s %b %i %{myname}s' resolvehosts="false"/> means:
- %s - output http status code of response
- %b - output bytes sent,excluding http headers, or '-' if 0
- %i - threadid
and %{myname}s meaning output value of attribute myname stored on session.
all good. if have hashmap stored on session, can output doing like:
%{mymap}s see http://tomcat.apache.org/tomcat-5.5-doc/config/valve.html more info.
but, want output value specific key, not entire map. have tried:
%{mymap.myatt}s but not work. ideas how this?
looking in source accesslogvalve, search string sessionattributeelement. value doing translate %{mymap}s string, , not can drill down map.
you extend class , override createaccesslogelement method add in handler different pattern (lets %{mymap.myatt}m), , handle logic in similar fashion sessionattributeelement class, split header session attribute name , map key.
Comments
Post a Comment