Search code examples
c#asp.nettracetracesourcesvctraceviewer

Tracing for an ASP.NET application does not work in production server


I need to trace the execution of my MVC 5 application, so i have added this to web.config file:

<system.diagnostics>
    <trace autoflush="true" indentsize="4" />
    <sources>
      <source name="mySource" switchValue="Information" switchType="System.Diagnostics.SourceSwitch">
        <listeners>
          <add name="sdt" type="System.Diagnostics.XmlWriterTraceListener" initializeData= "C:\inetpub\wwwroot\website\trace.log" />
        </listeners>
      </source>
    </sources>
  </system.diagnostics>

And in code, I added:

public static TraceSource _trace = new TraceSource("mySource");

_trace.TraceInformation("Tracing messages");

The problem is that nothing happens in production server. The log file is not even created.

The curious thing is that it does work in my development PC, using Release build. The web site was compiled with TRACE constant ON.

Production server has IIS 8.5 and in my PC, IISEXPRESS is used. That is the only difference.

Any help, please?


Solution

  • Could be an ACL issue.

    Check the security settings on C:\inetpub\wwwroot\website and compare them with the user your MVC application is running under.