-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Rich,
On 9/29/2011 9:18 AM, Richard Sayre wrote: > I am logging all local host access using the following config: > > <Valve className="org.apache.catalina.valves.AccessLogValve" > directory="logs" prefix="localhost_access_log." suffix=".txt" > pattern='%h %l %u %{userObject}s %t "%r" %s %b' > resolveHosts="false"/> > > > The userObject HttpSession attribute is a Java Object and right now > it is logging it by calling its toString method. Right. > I wanted to log a specific property of that object (userId) so I > tried %{userObject.userId}s but that did not print anything. Right. It's looking for an object in the session with the key "userObject.userId", rather than doing what you expect, which is to get "userObject" and then call "getUserId" on it with no arguments. AccessLogValve doesn't do that kind of thing: it's not very smart. (It's nice and fast, though). > Is it possible to log properties of an object that is in session? Not with the current code: you'd have to modify the AccessLogValve. > I can add the information to the toString method but I want avoid > that for now (I would have to re check the whole application 1500+ > pages to make sure that it is not called anywhere else). Honestly, no code should be depending on the return value of toString on any complex object. I'm not saying it doesn't happen... I'm just saying that it /shouldn't/ happen. Adding such a feature to AccessLogValve is certainly possible, but I'm sure that it won't be added to the "%{...}s" syntax because of the overhead of parsing the {...} to determine how to dereference and navigate the object tree, etc. Such code exists: it's available through any number of libraries and the syntax all looks the same or similar (Java EL, etc.): it just needs to be configured to do that. I'd be in support of a *new* escape sequence that would support this kind of thing because I think it would be useful but it needs to be distinct from the existing one so that it doesn't kill performance for everyone who is already using it. To be sure, AccessLogValve is intended to be run for every request, so speed is of the essence :) Patches are always welcome. - -chris -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk6ElvQACgkQ9CaO5/Lv0PBiuQCfUErS2/N6sbJ/CgfYPmc3CSZY ZhAAoLayLJI66d35xwsla/Y8lUboTcco =K166 -----END PGP SIGNATURE----- --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org