問(wèn)題描述
ColdFusion 代碼中是否有任何方法可以確定代碼在哪個(gè)服務(wù)器上執(zhí)行?我有幾個(gè)負(fù)載平衡的 ColdFusion 服務(wù)器.當(dāng)我捕捉到異常時(shí),我希望能夠知道代碼在哪個(gè)服務(wù)器上運(yùn)行,因此我可以將該信息包含在日志記錄/報(bào)告代碼中.
Is there any way in ColdFusion code to determine on what server the code is executing? I have few load-balanced ColdFusion servers. I want to be able to know on which server the code is running when I catch an exception, so I can include that information in the logging / reporting code.
如果重要的話,服務(wù)器是 Windows 2003/IIS.我也很想知道如何在 Linux/Apache 中做到這一點(diǎn).:-)
The servers are Windows 2003/IIS, if that matters. I'd love to know how to do it in Linux/Apache too. :-)
推薦答案
這可能會(huì)幫助您進(jìn)一步...
This may help you further...
<cfscript>
machineName = createObject("java", "java.net.InetAddress").localhost.getCanonicalHostName();
hostaddress = createObject("java", "java.net.InetAddress").localhost.getHostAddress();
</cfscript>
<cfdump var="#machineName#"><br />
<cfdump var="#hostaddress#"><br />
這篇關(guān)于在 ColdFusion 中,有沒(méi)有辦法確定代碼在哪個(gè)服務(wù)器上運(yùn)行?的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!