We have apache webserver as "entry" for incoming traffic it then delegates to tomcats with mod_jk.

We want to log the HTTP digest username, sample header:

Authorization: Digest username="Mufasa",

Unfortunately using the '%u' doesn't work as described. My guess is as we authenticate on tomcat side (apache delegates calls to tomcat with mod_jk) the own logging facility of apache doesn't know how to access the digest-username (because own auth module is bypassed).

To workaround this: Is there a custom log-format expression with regex matching for, e.g. telling to extract username="(.*?)" from 'Authorization' header and push to logs?

SetEnvIf Authorization username="([^"]+)" digest_username=$1
LogFormat "%h %l %{digest_username}e %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\"" combined_with_user
CustomLog /path/to/log combined_with_user

Haven't tested, so not sure if Apache is going to choke on the quotes in the SetEnvIf (they may need escaped) - but this should be pretty close.

  • thanks, this one looks promising. will accept answer when I tried out on our servers. – manuel aldana Oct 9 '11 at 20:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.