【发布时间】:2019-03-26 18:56:27
【问题描述】:
我正在尝试在 .NET Core 2.0 应用程序中捕获主机/服务器的 IP 地址。 ${machinename} 变量捕获服务器的名称,但如何捕获服务器的 IP 地址?这个名字对我的团队来说毫无意义,但 IP 地址很重要。
【问题讨论】:
-
可以有多个 IP 地址:stackoverflow.com/a/50386894/193178 您可以创建自己的自定义布局渲染器:github.com/NLog/NLog/wiki/How-to-write-a-custom-layout-renderer
-
我想要托管应用程序的机器的 IP 地址(不是主机名)。 github.com/NLog/NLog/wiki/AspNet-Request-IP-Layout-Renderer 会告诉我调用应用程序的客户端的 IP 地址。
-
既然你是从主机登录的,你不能给ip设置一个Event-Properties变量并在布局中使用它吗? github.com/NLog/NLog/wiki/EventProperties-Layout-Renderer
-
要使用的底层属性是什么?
标签: ip ip-address nlog host