Sometimes you need to know what hostnames are being resolved by your Java application. Name resolution takes time (since it may require network communication) and may slow down applications that perform many hostname name lookups. This small utility will tell you exactly when a heavyweight hostname resolution (calling native gethostbyname()) takes place. RMI applications are another example where you may need to know what hostnames are beng resolved and to what addresses.
The utility works by intercepting all calls to the name service provider using the ASM framework.
Download the dnslog.jar file (see below).
Run your Java application as usual just add the following as the first argument: -javaagent:dnslog.jar
for example:
java -javaagent:/home/genady/utils/dnslog.jar -classpath /home/genady/test/app.jar net.genady.demo.DNSDemo
Output:
Dec 25, 2006 12:16:52 PM net.genady.dns_log.DNSReportHelper reportLookupByName FINEST: Hostname "www.cnn.com" -> 64.236.16.52 64.236.16.84 ..... 64.236.16.20, lookup took 27ms Dec 25, 2006 12:16:53 PM net.genady.dns_log.DNSReportHelper reportLookupByName FINEST: Hostname "localhost" -> 127.0.0.1, lookup took 0ms Dec 25, 2006 12:16:53 PM net.genady.dns_log.DNSReportHelper reportLookupByName FINEST: Hostname "www-991.cnn.com", not found, lookup took 2250ms Dec 25, 2006 12:16:55 PM net.genady.dns_log.DNSReportHelper reportLookupByAddr FINEST: Address 72.249.16.189 -> www.genady.net, lookup took 101ms Dec 25, 2006 12:16:55 PM net.genady.dns_log.DNSReportHelper reportLookupByName FINEST: Hostname "www.genady.net" -> 72.249.16.189, lookup took 11ms
You can also use it through the logging API by adding the "=manual" text to the command line (like in -javaagent:dnslog.jar=manual, more details to come).
Windows, Linux
Java 5.0, Java 6.0 are supported.
JDK 1.4.2 and earlier are NOT supported, because they don't support the -javagent flag.
Free for non-commercial use. For usage in commercial envronment, contact dns-tools@genady.net
v4.0: - Download dnslog_v4.zip and extract dnslog.jar
Post them on the forum.
© 2002-18 Genady Beryozkin, rmi-info@genady.net. Read our Privacy policy. Hosted on RimuHosting. Visit Javalobby.