Возможно ли регистрировать исключения службы WCF? Я добавил в app.config. Но в файле журнала wcf отсутствует сообщение о мыле исключения. Все остальные сообщения, для которых нет исключений, можно увидеть в файле журнала WCF. Вот мой код & app.config. Любые указатели высоко оценены.WCF: как регистрировать исключения?
public string GetName(int employeeId)
{
string _fullName;
try
{
switch (employeeId)
{
case 1:
_fullName = "Dejan Dimitrovski";
break;
case 2:
_fullName = "John Doe";
break;
case 3:
_fullName = "Sue Marcus";
break;
case 4:
throw new Exception("test exception");
default:
_fullName = "N/A";
break;
}
}
catch (Exception ex)
{
throw new FaultException(ex.Message, new FaultCode("Server"));
}
return _fullName;
}
мой app.config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.diagnostics>
<sources>
<source name="System.ServiceModel" switchValue="Warning, ActivityTracing"
propagateActivity="true">
<listeners>
<add type="System.Diagnostics.DefaultTraceListener" name="Default">
<filter type="" />
</add>
<add name="ServiceModelTraceListener">
<filter type="" />
</add>
</listeners>
</source>
<source name="System.ServiceModel.MessageLogging" switchValue="Warning, ActivityTracing">
<listeners>
<add type="System.Diagnostics.DefaultTraceListener" name="Default">
<filter type="" />
</add>
<add name="ServiceModelMessageLoggingListener">
<filter type="" />
</add>
</listeners>
</source>
</sources>
<sharedListeners>
<add initializeData="app_tracelog.svclog" type="System.Diagnostics.XmlWriterTraceListener, System, Version=2.0.0.0,
 Culture=neutral, PublicKeyToken=b77a5c561934e089"
name="ServiceModelTraceListener" traceOutputOptions="Timestamp">
<filter type="" />
</add>
<add initializeData="app_messages.svclog"
type="System.Diagnostics.XmlWriterTraceListener, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
name="ServiceModelMessageLoggingListener" traceOutputOptions="Timestamp" >
<filter type="" />
</add>
</sharedListeners>
</system.diagnostics>
<system.serviceModel>
<diagnostics>
<messageLogging logEntireMessage="true"
logMalformedMessages="true"
logMessagesAtServiceLevel="true"
logMessagesAtTransportLevel="false" />
</diagnostics>
<behaviors>
<serviceBehaviors >
<behavior name="EmployeeService" >
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings />
<services>
<service behaviorConfiguration="EmployeeService" name="SoftLab.Wcf.Service.EmployeeService">
<endpoint name="basicHttpBinding"
address="basicEmployeeService"
binding="basicHttpBinding"
bindingNamespace="http://softlab.mkdot.net/binding/employee/2008/07"
contract="SoftLab.Wcf.Service.IEmployeeContract" />
<endpoint name="mex"
address="mex"
binding="mexHttpBinding"
bindingConfiguration=""
contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8000/" />
</baseAddresses>
</host>
</service>
</services>
</system.serviceModel>
</configuration>
@John Saunders, Спасибо за предложение. Я удалил свой try catch, хотя клиент получил исключение должным образом, сообщение об исключении не регистрируется. Только сообщение запроса регистрируется, но не ответ, который содержит исключение, не регистрируется. Не могли бы вы сообщить мне, что еще мне нужно изменить в моей конфигурации? – funwithcoding
@funwithcoding: вы регистрируетесь на клиенте или на сервере? –
Я вхожу на сервер. – funwithcoding