简体   繁体   English

IIS运行时日志记录

[英]IIS run-time logging

I started a new, from scratch, MVC4 web application. 我从头开始了一个新的MVC4 Web应用程序。

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. 我在VS / Express中运行了该网站,然后点击了“关于”页面。 In the run-time Output (Ctrl-Alt-O)/Debug window I see my lines of code working. 在运行时输出(Ctrl-Alt-O)/ Debug窗口中,我看到了我的代码行。

Next close VS & I stand the site up in real IIS & hit the 'About' page. 下一步关闭VS,我将站点站在真实的IIS中,然后单击“关于”页面。

Where do I go and find the diagnostic output? 我在哪里可以找到诊断输出? Because it isn't in the inetpub/logs or Event Viewer. 因为它不在inetpub / logs或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. 一旦找到答案,我将删除这两个之一。

-- web.config I tacked it onto the end/just inside the /configuration. -web.config我将其添加到/ configuration内部的末尾。 & as shown designated file is be created & written to in the root of the web application--- &如图所示,将在Web应用程序的根目录中创建并写入指定文件-

  <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(). 但是您必须... Trace.Flush()。 autoflush=true appears to not change help anything. autoflush=true似乎不改变任何帮助。

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();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM