Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 658473
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T22:56:15+00:00 2026-05-13T22:56:15+00:00

Is it possible to log WCF service exceptions? I have added in the app.config.

  • 0

Is it possible to log WCF service exceptions? I have added in the app.config. But still the exception soap message is missing in the wcf log file. All the remaining messages for which there is no exceptions can be seen in the WCF log file. Here is my code & app.config. Any pointers are highly appreciated.

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;
}

my 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,&#xD;&#xA;          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>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T22:56:16+00:00Added an answer on May 13, 2026 at 10:56 pm

    WCF logs all unhandled exceptions. You have handled the exception and returned a fault instead.

    Try removing the try/catch block. I think your client will notice nearly the same message coming back, and you’ll have your exceptions logged.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple WCF service that is used for cross app-domain communication in
I have a WCF service with several methods. I would like to log the
I have some .Net WCF services, for these services I have configured the app.config
It is possible in SQL Server Express have a log of all operations SELECT
Is it possible to have 2 applications write to the same log file using
I have a few log files like these: /var/log/pureftpd.log /var/log/pureftpd.log-20100328 /var/log/pureftpd.log-20100322 Is it possible
I write WCF service and want to keep it's activity log: trace, warnings and
I've got a WCF service that's using Enterprise Library for its Exception Handling and
Lets suppose I have an .NET client application that connects to a WCF service,
I have a WCF Service running fine on my local machine. I put it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.