Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am using Apache as a load balancer and would like to log the server to which the load balancer is forwarding the request to. For example, if I had three webservers, called:

  • webserver1 - 192.168.0.1
  • webserver2 - 192.168.0.2
  • webserver3 - 192.168.0.3

I would like the log to show me to which server the request was forwared to (denoted by bold):

10.1.0.1 192.168.0.1 - - [20/Jul/2010:10:52:01 -0600] "GET /js/shared/kobj-static.js HTTP/1.1" 302 236 "http://www.google.com/search?q=baked+bbq+rib+recipes&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a" "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.6) Gecko/20100625 Firefox/3.6.6 (.NET CLR 3.5.30729) infoCard/AzigoLite/0.0.12"

Any help would be appreciated.

share|improve this question

1 Answer 1

up vote 2 down vote accepted

You can use the Custom log format to do that. One way I think you can do is to add the environment variable to the log. mod_proxy_balancer (that I suppose you are using) exports BALANCER_WORKER_NAME variable that is the name of the Worker used for the request. You can use the %{BALANCER_WORKER_NAME}e directive on your Custom Log format string to get that logged. This is an example of the default debian 'combined' log format with the directive added:

LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" \"%{BALANCER_WORKER_NAME}e\"" combined
share|improve this answer
    
That did it.. I greatly appreciate the quick response and help. Regards –  QWade Jul 20 '10 at 19:47

Your Answer

 
discard

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.