Exception handling & Logging in WCF

Posted by Krishnasamy2008 under WCF on 4/4/2012 | Points: 10 | Views : 3126 | Status : [Member] | Replies : 2
Hi Friends,

How to handle exceptions & logging in WCF services.Now i'm develping the services using schema first concept.Do I need to create the fault contracts and handle them? Could you please post some information on this or else some url reference?


Thanks,
Krishna.K




Responses

Posted by: Sakthi.Singaravel on: 4/4/2012 [Member] Silver | Points: 25

Up
0
Down
Hi Mr.Krishnasamy,

I think this link may be helpful for u..
http://msdn.microsoft.com/en-us/library/gg281715.aspx


Regards,
Singaravel M

Krishnasamy2008, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: arun_ymail-14946 on: 4/17/2012 [Member] Starter | Points: 25

Up
0
Down
For logging u need to configure devenv.exe.config file
Ex..
<configuration>
<configSections>
<section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" />
<section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<section name="msbuildToolsets" type="Microsoft.Build.BuildEngine.ToolsetConfigurationSection, Microsoft.Build.Engine, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</configSections>
<loggingConfiguration name="Logging Application Block" tracingEnabled="false"
defaultCategory="Info" logWarningsWhenNoCategoriesMatch="false">
<listeners>
<add source="Enterprise Library Logging" formatter="Logging Formatter"
log="Application" machineName="" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FormattedEventLogTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
traceOutputOptions="None" filter="All" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FormattedEventLogTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
name="Formatted EventLog TraceListener" />
<add fileName="F:\Projects\common\projectName\Logfilename.txt"
footer="---------------------------------" formatter="Logging Formatter"
header="---------------------------------" rollFileExistsBehavior="Increment"
rollInterval="None" rollSizeKB="20480" timeStampPattern="dddd, MMMM dd yyyy"
listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.RollingFlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
traceOutputOptions="None" filter="All" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.RollingFlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
name="Rolling Flat File Trace Listener" />
</listeners>
<formatters>
<add template="Timestamp: {timestamp(local:yyyy-MM-dd HH:mm:ss.fff)}&#xD;&#xA;Message: {message}&#xD;&#xA;Category: {category}&#xD;&#xA;Priority: {priority}&#xD;&#xA;Severity: {severity}&#xD;&#xA;&#xD;&#xA;"
type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
name="Logging Formatter" />
</formatters>
<logFilters>
<add categoryFilterMode="DenyAllExceptAllowed" type="Microsoft.Practices.EnterpriseLibrary.Logging.Filters.CategoryFilter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
name="Category Filter">
<categoryFilters>
<add name="Error" />
<add name="Info" />
</categoryFilters>
</add>
<add enabled="true" type="Microsoft.Practices.EnterpriseLibrary.Logging.Filters.LogEnabledFilter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
name="LogEnabled Filter" />
</logFilters>
<categorySources>
<add switchValue="All" name="Debug">
<listeners>
<add name="Rolling Flat File Trace Listener" />
</listeners>
</add>
<add switchValue="All" name="Decrypted">
<listeners>
<add name="Rolling Flat File Trace Listener" />
</listeners>
</add>
<add switchValue="All" name="Error">
<listeners>
<add name="Rolling Flat File Trace Listener" />
</listeners>
</add>
<add switchValue="All" name="Info">
<listeners>
<add name="Rolling Flat File Trace Listener" />
</listeners>
</add>
<add switchValue="All" name="Timing">
<listeners>
<add name="Rolling Flat File Trace Listener" />
</listeners>
</add>
</categorySources>
<specialSources>
<allEvents switchValue="All" name="All Events" />
<notProcessed switchValue="All" name="Unprocessed Category" />
<errors switchValue="All" name="Logging Errors &amp; Warnings">
<listeners>
<add name="Formatted EventLog TraceListener" />
</listeners>
</errors>
</specialSources>
</loggingConfiguration>




Krishnasamy2008, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response