Forum Moderators: phranque

Message Too Old, No Replies

Resolving IP adresses

How can I get host name in adition to the IP adresses in access.log

         

phpabdel

4:00 pm on Apr 25, 2005 (gmt 0)

10+ Year Member



Hello webmasters,
I need to get hostnames instead of IP adresses in the access.log log file generated by Apache, in the httpd.con I have the %h (which normally stands for hostname) tag in the LogFormat configuration line as shown below:

-------------------------------------
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" \"%{SaneCookie}n\" %<{SaneStop}n %T" sane
---------------------------------------
but only IP adresses are loged into access.log! :-¦
can somebody tell me how to overcome this probleme.
thankyou in advance.

Webmasterly yours.
Abdel.

jdMorgan

7:50 pm on Apr 25, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Abdel,

Welcome to WebmasterWorld!

Are you self-hosting, or are you using a hosting service?

Hosting services often disable this feature because it requires that your server issue a reverse-DNS lookup request for each request received by your server. This slows down the server quite a bit, doubles the server's communication traffic, and adds load to the CPU. For this reason, hosting services often disable it.

If this does not concern you, see HostnameLookups [httpd.apache.org] in Apache core. If you have access to httpd.conf, you can enable this feature.

Jim

sitz

1:15 am on Apr 26, 2005 (gmt 0)

10+ Year Member



As a follow-up, if you only need the hostnames for your web statistics, you can post-process the logs, performing reverse DNS lookups on the IPs as you go. This allows you to figure out which hostnames are making requests of your server while at the same time preserving the current performance characteristics. As a for-instance, webalizer [mrunix.net] has an option to do this when performing log processing. I'm a middlin' fan of this application; it does the basics very well, but has one 'feature' that makes life a little difficult if your site is powered by multiple servers, and doesn't provide quite as much detail as I'm looking for personally. OTOH, it's crazyfast and free; can't beat the price. =)

If you find you MUST run with Apache performing hostname look-ups, I strongly recommend running a local caching-only nameserver on the box, and adding 127.0.0.1 to your resolv.conf; make sure (for security reasons) that your resolver (generally BIND [isc.org], although there are others) is listening *ONLY* on 127.0.0.1. This will boost performance, since your local nameserver will only have to look up a given IP once every few hours/days, instead of for every request. More information on configuring BIND can be found on Google [google.com] or in the cricket book [oreilly.com].

phpabdel

8:12 am on Apr 26, 2005 (gmt 0)

10+ Year Member



Hello men,

All right men, I turned on the HostnameLookups to On, and it to work, for the moment, this is just in the test machine, I'll try it in the production server and see if it works.

Good day.
Mebmasterly.
Abdel.