Search code examples
apachelogginguserid

userid is not printed in Apache access logs


I have a production setup as

  webSEAL --> F5 --> 2 Apache --- 2 weblogic servers.

For every request webSEAL logs prints logged-in user-id and weblogic which is at the very last in infrastructure chain also have the user-id available in weblogic http access.log (not application log but weblogic internal access logs) but there's nothing shown in Apache.

Even when I added new logging configuration at apache, it's not printing the user_id in apache access logs.It just print a dash - (information not available).

following is the added configuration in httpd.conf and output.

LogFormat "%h %V %u %t \"%r\" %>s" test
CustomLog logs/testLogs testFormat

***192.168.44.53 localhost - [11/Jun/2015:23:21:39 +0200] "HEAD / HTTP/1.1" 200*** 

What else do I need to do to "make user-id available to Apache instance".

This is the reference for Apache 2.0X which I'm using in my environment. http://httpd.apache.org/docs/2.0/logs.html


Solution

  • The %u pattern code logs the remote username if the request was authenticated with HTTP Basic or Digest authentication. In the example log entry this value is "-", meaning that the request was not authenticated with HTTP Basic or Digest authentication.

    You can use Apache to log client IP addresses utilizing X-Forwarded-For headers .

    The standard LogFormat directive: LogFormat “%h %l %u %t “%r” %>s %b” common

    To add the clients source IP address, just change this to: LogFormat “%h %l %u %t “%r” %>s %b %{X-Forwarded-For}i” common

    Standard logs: 192.168.2.210 – – [09/Feb/2011:09:59:31 +0000] “GET / HTTP/1.1″ 200 44

    Client IP’s added: 192.168.2.210 – – [09/Feb/2011:10:00:16 +0000] “GET / HTTP/1.1″ 200 44 192.168.2.7