1
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>
@ 존 손더스, 제안에 감사드립니다. 클라이언트가 예외를 제대로 받았지만 예외 메시지가 기록되지 않고 try catch를 제거했습니다. 요청 메시지 만 기록되지만 예외가 포함 된 응답은 기록되지 않습니다. 제 설정에서 변경해야 할 것이 있다면 알려주십시오. – funwithcoding
@funwithcoding : 클라이언트 또는 서버에 로그온 하시겠습니까? –
서버에 로그온 중입니다. – funwithcoding