如何停止IISExpress将每个请求的每个细节都转储到Visual Studio输出窗口中?

26

我的VS 2013输出窗口充满了这样的内容:

iisexpress.exe Information: 0 : Request, Method=GET, Url=http://localhost:51741/api/Clients/?$filter=UniqueName eq '6269', Message='http://localhost:51741/api/Clients/?$filter=UniqueName eq '6269''
iisexpress.exe Information: 0 : Message='Clients', Operation=DefaultHttpControllerSelector.SelectController
iisexpress.exe Information: 0 : Message='MyProj.Controllers.ClientsController', Operation=DefaultHttpControllerActivator.Create
iisexpress.exe Information: 0 : Message='MyProj.Controllers.ClientsController', Operation=HttpControllerDescriptor.CreateController
iisexpress.exe Information: 0 : Message='Selected action 'GetClients()'', Operation=ApiControllerActionSelector.SelectAction
iisexpress.exe Information: 0 : Operation=HttpActionBinding.ExecuteBindingAsync
iisexpress.exe Information: 0 : Operation=QueryableAttribute.ActionExecuting
iisexpress.exe Information: 0 : Message='Action returned 'System.Collections.Generic.List`1[MyProj.Models.ClientDto]'', Operation=ReflectedHttpActionDescriptor.ExecuteAsync
iisexpress.exe Information: 0 : Message='Will use same 'JsonMediaTypeFormatter' formatter', Operation=JsonMediaTypeFormatter.GetPerRequestFormatterInstance
iisexpress.exe Information: 0 : Message='Selected formatter='JsonMediaTypeFormatter', content-type='application/json; charset=utf-8'', Operation=DefaultContentNegotiator.Negotiate
iisexpress.exe Information: 0 : Operation=ApiControllerActionInvoker.InvokeActionAsync, Status=200 (OK)
iisexpress.exe Information: 0 : Operation=QueryableAttribute.ActionExecuted, Status=200 (OK)
iisexpress.exe Information: 0 : Operation=ClientsController.ExecuteAsync, Status=200 (OK)
iisexpress.exe Information: 0 : Response, Status=200 (OK), Method=GET, Url=http://localhost:51741/api/Clients/?$filter=UniqueName eq '6269', Message='Content-type='application/json; charset=utf-8', content-length=unknown'
iisexpress.exe Information: 0 : Operation=JsonMediaTypeFormatter.WriteToStreamAsync
iisexpress.exe Information: 0 : Operation=ClientsController.Dispose

我该如何关闭所有这些?我只想看到我的调用Trace.TraceInformationTrace.TraceErrorTrace.TraceWarning等。

3个回答

25

首先,当您使用像

Trace.TraceInformation("My Custom Info Message.");

如果要跟踪代码(无论是从页面、控制器还是其他独立的.dll文件中),然后在IIS Express下运行应用程序,MS VS输出窗口会显示类似以下内容:

iisexpress.exe Information: 0 : My Custom Info Message.

你如何区分哪些消息是“你的”,哪些不是“你的”?也许你应该为每个你的消息添加额外的标记?但是据我所见,输出窗口仍不支持通过自定义标签或文本进行消息过滤,但它支持文本搜索(Ctrl+F),因此...
我也遇到了与IIS Express类似的问题,它会向输出窗口发送诸如此类的消息。
'iisexpress.exe' (CLR v4.0.30319: /LM/W3SVC/2/ROOT-1-130838650006648508): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Runtime.Serialization\v4.0_4.0.0.0__b77a5c561934e089\System.Runtime.Serialization.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.

我通过进入 MS VS (2013) 的主菜单,选择 DEBUG -> Options & Settings... -> Debugging -> Output Window,并关闭不必要的输出消息类型来解决了这个问题。

General Output Settings


11
你可以通过右键单击输出窗口并切换它们的开关来从上下文菜单中设置这些选项。我关闭了“模块加载消息”和“模块卸载消息”。 - crush
非常好,谢谢您。现在我只需要摆脱那些烦人的亿万行“应用洞察”输出。 - ProfK
1
我希望我能为你点赞40次。 - Gargoyle

7
App_Start\WebApiConfig.cs文件中,删除config.EnableSystemDiagnosticsTracing();代码。就这么简单 :facepalm:

2
我的WebApiConfig中没有那行代码,但我仍然收到这些消息。 - crush
我仍然可以收到没有那行代码的消息,但如果有了它,我不想只是放弃所有跟踪。我宁愿使用System.Web.Http.Tracing.SystemDiagnosticsTraceWriter,这是EnableSystemDiagnosticsTracing返回的内容,来配置系统跟踪,例如设置更高的MinimumLevel或其他内容。 - ProfK

0

这个应该放在 applicationhost.config 的哪里? - epalm
忽略位置,尝试使用 system.webServer 节点。结果可能因人而异。 - Erik Philips

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接