0

I started a new, from scratch, MVC4 web application.

I added my two lines of code into the 'About' Controller.

System.Diagnostics.Debug.WriteLine("HELLO WORLD - debug");
System.Diagnostics.Trace.WriteLine("HELLO WORLD - trace");

I ran the site in VS/Express and hit the 'About' page. In the run-time Output (Ctrl-Alt-O)/Debug window I see my lines of code working.

Next close VS & I stand the site up in real IIS & hit the 'About' page.

Where do I go and find the diagnostic output? Because it isn't in the inetpub/logs or Event Viewer.

I post a much more extensive version of this question elsewhere. I'll be deleting one of these two once I get to the bottom of this answer.

user5903880
  • 102
  • 8
  • Set up a proper trace listener in the `` section of your web.config. – Cᴏʀʏ Jul 13 '17 at 17:51
  • Possible duplicate of [Trace logs location, where to view them](https://stackoverflow.com/questions/25286180/trace-logs-location-where-to-view-them) – Cᴏʀʏ Jul 13 '17 at 17:51
  • @Cory I've been waiting years to find you. That worked. – user5903880 Jul 13 '17 at 18:08
  • If you want a real recommendation for a logging solution, look into [Serilog](https://serilog.net/) combined with [SEQ](https://getseq.net/). Our developers are ecstatic about it. Far easier to configure than trace logging from IIS, and far more useful. – mason Jul 13 '17 at 18:15

1 Answers1

0

-- web.config I tacked it onto the end/just inside the /configuration. & as shown designated file is be created & written to in the root of the web application---

  <system.diagnostics>  
    <trace autoflush="false
    " indentsize="4">  
      <listeners>  
        <add name="myListener" type="System.Diagnostics.TextWriterTraceListener" initializeData="TextWriterOutput.log" />  
        <remove name="Default" />  
      </listeners>  
    </trace>  
  </system.diagnostics>  

In your code. Any of these three will log to the designated file. But you HAVE to ...Trace.Flush(). autoflush=true appears to not change help anything.

System.Diagnostics.Debug.WriteLine("HELLO WORLD ~ debug");
//System.Diagnostics.Trace.WriteLine("HELLO WORLD ~ trace");
//System.Diagnostics.Trace.TraceInformation("HELLO WORLD ~ traceInfo");
System.Diagnostics.Trace.Flush();

user5903880
  • 102
  • 8