Web Trenches

Where am I?



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. 

One Reply to “Where am I?”

Leave a Reply

Your email address will not be published. Required fields are marked *