Forum OpenACS Q&A: Response to Storing cookie info or user IDs in the access log

With reference to Vadim's suggestion, more specifically, in OACS 3.x what you'd do is put the following lines in sec_read_security_info before return "filter_ok":
    if [info exists ad_sec_user_id] {
        set user_id $ad_sec_user_id
    } else {
        set user_id 0
    }
    ns_set put [ns_conn headers] X-User-Id "user_id=$user_id"
Should this go in as a patch?  How harmless is it?  Does putting the user_id in the HTTP headers matter if the user id is often in the url anyway?  Is there a performance impact?  Should we make this the default behavior in conjunction with adding matching code to config.tcl to capture it?  Does the extra data in the access log break the standard log format?
Joel, it is completely harmless, as the user_id is being added to the incoming HTTP headers not any outgoing headers. Yes, it sounds odd, but that is actually the way it works. And no, adding the extra data to the access log shouldn't break anything trying to read it.

Here are yet three more threads dicussing this issue: Nov. 2001, May 2002, April 2003.

Collapse
Posted by Andrew Piskorski on
As I mentioned back in 2002, it is easy to write the OpenACS user_id to the AOLserver access log on each and every hit. However, when an error occurs, it would be really nice if the user_id was included with the error stack trace in the error log, but there is no obvious way to do this.

Has anyone since come up with a way to log the user_id to the error log whenever a page throws a Tcl error?