Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 1 down vote accepted
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.

share|improve this answer
thanks, this one looks promising. will accept answer when I tried out on our servers. – manuel aldana Oct 9 '11 at 20:44
works like a charm, thanks again! – manuel aldana Oct 11 '11 at 6:56

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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