Where am I?

Aug 21, 2007

If you run load-balanced ColdFusion servers, it can often to difficult to determine which server a notification or error message originated from.  There's a nice little Java trick to get around this. 

---
#Createobject('java','java.net.InetAddress').getLocalHost().getHostName()#
--- 

We add this line to error notifications on our site so that we always know which physical machine the message came from.   This makes it a little easier to diagnose a problem, determine if it is limited to one server, and know which log files to look at. 

This is also great if your site is responding a bit slow and you want to know which server in the setup you are hitting from your machine.  We set up a small script called whereami.cfm that simply displays the machine name. 

Comments

Write your comment



(it will not be displayed)





About Michael Sprague

Mike is a Web developer and manager from Central New York, specializing in ColdFusion, CSS, JavaScript, and Ajax development. More ...

Categories

Monthly Archives

Favorite Bloggers

Web Resources