Skip to content

Instantly share code, notes, and snippets.

@vbilopav
Created September 1, 2015 13:33
Show Gist options
  • Save vbilopav/e6139450da892a6956e8 to your computer and use it in GitHub Desktop.
Save vbilopav/e6139450da892a6956e8 to your computer and use it in GitHub Desktop.
public void LogRequest()
{
if (OperationContext.Current == null) return;
string msg = String.Empty;
if (Properties.ContainsKey(RemoteEndpointMessageProperty.Name))
{
RemoteEndpointMessageProperty remote =
Properties[RemoteEndpointMessageProperty.Name] as RemoteEndpointMessageProperty;
if (remote != null)
msg = string.Format("request from [{0}]:{1}\n", remote.Address, remote.Port);
}
else
msg = "request from unknown source\n";
msg = string.Concat(msg, Properties.ContainsKey("Encoder") ?
OperationContext.Current.RequestContext.RequestMessage.ToString() :
Properties.Via.ToString());
Log.Info(msg);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment