在 ColdFusion 中,有没有办法确定代码在哪个服务器上运行?

2022-01-09 00:00:00 networking coldfusion java

ColdFusion 代码中是否有任何方法可以确定代码在哪个服务器上执行?我有几个负载平衡的 ColdFusion 服务器.当我捕捉到异常时,我希望能够知道代码在哪个服务器上运行,因此我可以将该信息包含在日志记录/报告代码中.

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.

如果重要的话,服务器是 Windows 2003/IIS.我也很想知道如何在 Linux/Apache 中做到这一点.:-)

The servers are Windows 2003/IIS, if that matters. I'd love to know how to do it in Linux/Apache too. :-)

推荐答案

这可能会帮助您进一步...

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 />

相关文章