我想知道是否有人能告訴我如何從我的wcf rest服務記錄一個簡單的請求/響應。WCF/REST日誌記錄
我自己用的LOCALMACHINE控制檯應用程序託管:
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
string baseAddress = "http://" + Environment.MachineName + ":8000/Service";
ServiceHost host = new ServiceHost(typeof(RawDataService), new Uri(baseAddress));
WebHttpBinding binding = new WebHttpBinding();
//binding.Security.Mode = WebHttpSecurityMode.Transport;
host.AddServiceEndpoint(typeof(IReceiveData), new WebHttpBinding(), "").Behaviors.Add(new WebHttpBehavior());
host.Open();
Console.WriteLine("Host opened");
Console.ReadLine();
}
}
}
我真的很希望所有將需要的東西加入到託管控制檯應用程序。我嘗試了下面這個,但它有點混亂http://blogs.msdn.com/b/carlosfigueira/archive/2011/04/19/wcf-extensibility-message-inspectors.aspx
只是爲了說明我沒有使用任何app.config或web.config文件。
編輯:
我也不能使用任何第三方產品。
在你的日誌記錄攔截器類,一定要包括'使用Castle.DynamicProxy' - 記住這是第三部分庫,所以如果你沒有它,你可以從NuGet獲得或直接從[Castle Project](http://www.castleproject.org/castle/download.html)下載。您需要爲'Castle.Core'和'Castle.Windsor'的項目添加引用。 – 2012-04-28 16:12:50
Ahh抱歉Rob我無法使用任何第三方產品。我的錯誤是沒有在問題中提到這一點。現在會更新。 – 2012-04-28 16:14:41