HTTP Header logging irule

Every now and then during troubleshooting you need more insight on headers and cookies passing the BIG-IP HTTP reverse proxy.
I found this iRule on DC, but for quick reference gave it a place on my site.

Original article: DC log http headers

when HTTP_REQUEST {
   set LogString "Client [IP::client_addr]:[TCP::client_port] -> [HTTP::host][HTTP::uri]"
   log local0. "============================================="
   log local0. "$LogString (request)"
   foreach aHeader [HTTP::header names] {
      log local0. "$aHeader: [HTTP::header values $aHeader]"
   }
   log local0. "============================================="
}
when HTTP_RESPONSE {
   log local0. "============================================="
   log local0. "$LogString (response) - status: [HTTP::status]"
   foreach aHeader [HTTP::header names] {
      log local0. "$aHeader: [HTTP::header values $aHeader]"
   }
   log local0. "============================================="   
}