Linking Custom Config File to Machine Config File

There is configSource attribute with help of which content of the Machine.config file can be redirected to the custom config file.


Below is the sample


<system.diagnostics configSource="GlobalDiagnostics.config">



For the system diganostic section in machine.config file a seperate  config file is been created, file name is GlobalDiagnostic.config. Global diagnostic file can then contain the diagnostics related configurations. Below is the sample content of the  


<?xml version="1.0" encoding="utf-8"?>



    <add name="CustomTraceListener" type="Instrumentation.Framework.CustomTraceListener, Instrumentation.Framework, Version=, Culture=neutral, PublicKeyToken=b40e65bd72b277e3" traceOutputOptions="LogicalOperationStack" />



    <add name="Debug" value="Verbose,ActivityTracing" />

    <add name="TraceSourceSwitch" value="All" />


  <trace autoflush="true" indentsize="4" />


    <source name="TestEventSource" switchType="System.Diagnostics.SourceSwitch" switchName=" TraceSourceSwitch ">


        <remove name="Default" />

        <add name="CustomTraceListener" />






But this has limitation that config file must be in the same or sub folder, the path has to be below the current path of the machine config file.