Overriding system.diagnostics in a subdirectory web.config
I am attempting to enable WCF message tracing for a single service (one of several included in this IIS application).  I have created a web.config file that is placed in the same physical directory as my .svc file.  I am able to configure the service from this web.config file, modifying behaviors, endpoints etc.  However, when I attempt to include the include a system.diagnostics node, it appears to have no effect.  This does not produce a trace file:

<!-- language: lang-xml -->

    <?xml version="1.0"?>
    <configuration>
        <system.serviceModel>    
            <services>
                <service name="My.Awesome.Wcf.Service" />
                <!-- my endpoints and behaviors are defined programmatically -->
            </services>
    
            <diagnostics>
                <messageLogging
                     logEntireMessage="true"
                     logMalformedMessages="true"
                     logMessagesAtServiceLevel="true"
                     logMessagesAtTransportLevel="true"
                     maxMessagesToLog="3000" />
            </diagnostics>
        </system.serviceModel>
    
        <system.diagnostics>
            <sources>
                <source name="System.ServiceModel"
                        switchValue="Information, ActivityTracing"
                        propagateActivity="true" >
                    <listeners>
                        <add name="xml"/>
                    </listeners>
                </source>
                <source name="System.ServiceModel.MessageLogging">
                    <listeners>
                        <add name="xml"/>
                    </listeners>
                </source>
            </sources>
            <sharedListeners>
                <add name="xml"
                     type="System.Diagnostics.XmlWriterTraceListener"
                           initializeData="C:\logs\Traces.svclog" />
            </sharedListeners>
            <trace autoflush="true" />
        </system.diagnostics>
    </configuration>

If I move the entire system.diagnostics node out of this sub-directory web.config to the application's root web.config, then it magically starts working.  As far as I can tell, the system.diagnostics section is not limited to the application's root web.config, since my machine.config shows this section definition:

<!-- language: lang-xml -->

    <section name="system.diagnostics" type="System.Diagnostics.SystemDiagnosticsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>

Note that this definition does not include an "allowDefinition" attribute, which, according to this [MSDN documentation for the section element][1] means that it can be defined "Everywhere" which should include physical subdirectories.  I have not been able to find any system.diagnostics definitions in any parent web.configs either.

Does anyone know why this system.diagnostics configuration might not be getting processed?


  [1]: http://msdn.microsoft.com/en-us/library/ms228245.aspx
Overriding system.diagnostics in a subdirectory web.config
===

I am attempting to enable WCF message tracing for a single service (one of several included in this IIS application).  I have created a web.config file that is placed in the same physical directory as my .svc file.  I am able to configure the service from this web.config file, modifying behaviors, endpoints etc.  However, when I attempt to include the include a system.diagnostics node, it appears to have no effect.  This does not produce a trace file:

<!-- language: lang-xml -->

    <?xml version="1.0"?>
    <configuration>
        <system.serviceModel>    
            <services>
                <service name="My.Awesome.Wcf.Service" />
                <!-- my endpoints and behaviors are defined programmatically -->
            </services>
    
            <diagnostics>
                <messageLogging
                     logEntireMessage="true"
                     logMalformedMessages="true"
                     logMessagesAtServiceLevel="true"
                     logMessagesAtTransportLevel="true"
                     maxMessagesToLog="3000" />
            </diagnostics>
        </system.serviceModel>
    
        <system.diagnostics>
            <sources>
                <source name="System.ServiceModel"
                        switchValue="Information, ActivityTracing"
                        propagateActivity="true" >
                    <listeners>
                        <add name="xml"/>
                    </listeners>
                </source>
                <source name="System.ServiceModel.MessageLogging">
                    <listeners>
                        <add name="xml"/>
                    </listeners>
                </source>
            </sources>
            <sharedListeners>
                <add name="xml"
                     type="System.Diagnostics.XmlWriterTraceListener"
                           initializeData="C:\logs\Traces.svclog" />
            </sharedListeners>
            <trace autoflush="true" />
        </system.diagnostics>
    </configuration>

If I move the entire system.diagnostics node out of this sub-directory web.config to the application's root web.config, then it magically starts working.  As far as I can tell, the system.diagnostics section is not limited to the application's root web.config, since my machine.config shows this section definition:

<!-- language: lang-xml -->

    <section name="system.diagnostics" type="System.Diagnostics.SystemDiagnosticsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>

Note that this definition does not include an "allowDefinition" attribute, which, according to this [MSDN documentation for the section element][1] means that it can be defined "Everywhere" which should include physical subdirectories.  I have not been able to find any system.diagnostics definitions in any parent web.configs either.

Does anyone know why this system.diagnostics configuration might not be getting processed?


  [1]: http://msdn.microsoft.com/en-us/library/ms228245.aspx