microsoft / ApplicationInsights-dotnet-logging

.NET Logging adaptors
106 stars 49 forks source link

Web.config transformation is not applied correctly when using configSource #156

Closed Vivelin closed 6 years ago

Vivelin commented 6 years ago

When you install the TraceListener package, it adds the trace listener to the system.diagnostics section in the web.config file. However, we're using the configSource attribute to configure trace listeners and sources in a separate file. When I install the package, it results in the following:

<system.diagnostics configSource="trace.config">
  <trace autoflush="true" indentsize="0">
    <listeners>
      <add name="myAppInsightsListener" type="Microsoft.ApplicationInsights.TraceListener.ApplicationInsightsTraceListener, Microsoft.ApplicationInsights.TraceListener" />
    </listeners>
  </trace>
</system.diagnostics>

I am not very familiar with the internals of the configuration, but I believe the configSource overrides web.config in this case. If there is a configSource present, I think it should modify the configSource file, or at the very least not modify the web.config incorrectly.

TimothyMothra commented 6 years ago

Hi @Vivelin. I agree this is inconvenient. Unfortunately, install.xdt scritpts won't allow us to target an external config file

In your opinion, is it better to 1) provide this sample config for you to copy to your configSource, or 2) would it be better to inject no config at all?

Vivelin commented 6 years ago

I'm not sure what the options are for providing a sample. The documentation on Application Insights is pretty clear and I am personally knowledgeable about trace listener configuration but my coworkers are less familiar with the system and would probably benefit from some sample they can copy.

TimothyMothra commented 6 years ago

Glad to hear someone likes our documentation! :)

I'll mark this as "documentation" for now and I'll make sure this gets discussed in our next planning meeting.