SeT*_*ToY 4 c# wcf nlog ip-address
我在我的WCF服务中使用NLog,并希望记录呼叫者IP地址.
我已经使用ASPNET-LayoutRenderers试过(${aspnet-request:serverVariable=remote_host}
,${aspnet-request:serverVariable=remote_addr}
,但无济于事,作为内部NLOG异常被抛出,正在生成日志文件.
有没有办法在WCF服务中记录IP地址,而无需将其作为参数传递给被调用的方法?
var msg = OperationContext.Current
.IncomingMessageProperties[RemoteEndpointMessageProperty.Name] as RemoteEndpointMessageProperty;
var address = msg.Address;
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
1604 次 |
最近记录: |