以下是三个日志exmaples:
127.0.0.1 - - [17/Sep/2010:14:03:07 +0800] "GET /docs/logging.html HTTP/1.1" 200 24040 "http://localhost:8000/docs/manager-howto.html" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)" 0:0:0:0:0:0:0:1 - - [26/Oct/2010:09:53:30 +0800] "GET /docs/images/tomcat.gif HTTP/1.1" 200 1934 "http://localhost:8000/docs/" "Mozilla/5.0 (Windows; U; Windows NT 6.1; zh-CN; rv:1.9.2.8) Gecko/20100722 Firefox/3.6.8" 0:0:0:0:0:0:0:1 - - [26/Oct/2010:09:53:30 +0800] "GET /docs/images/asf-logo.gif HTTP/1.1" 200 7279 "http://localhost:8000/docs/" "Mozilla/5.0 (Windows; U; Windows NT 6.1; zh-CN; rv:1.9.2.8) Gecko/20100722 Firefox/3.6.8"
第一个是正确的。但是,第二个和第三个IP是IPv6格式,如何避免这种情况?
答案 0 :(得分:3)
我在Tomcat 6.0.20上观察到当我以localhost:8080
访问它时会显示IPv6地址,而当我使用IP地址访问它时会显示IPv4(即点十进制表示法)或服务器名称。
访问该URL的任何远程用户也将显示ipv4表示法。
通过IP地址或域名:
172.x.x.x - - [26/Oct/2010:11:19:50 +0530] "GET /examples/servlets/servlet/RequestParamExample HTTP/1.1" 200 665
通过localhost:
0:0:0:0:0:0:0:1 - - [26/Oct/2010:11:20:54 +0530] "GET /examples/servlets/servlet/HelloWorldExample HTTP/1.1" 200 359
对你来说它是否也一样?