How do I prevent ASP.NET from logging authentication failures?

五迷三道 提交于 2019-12-11 03:55:15

问题


My Windows Azure web role ASP.NET MVC application serves REST API requests on some of the routes and those routes require "basic" authentication. Client programs often fail to authenticate - most of them are in the middle of being debugged - and so authentication failures are quite common. For every event I get a record like this in the Application log (accessible via Event Viewer or System.Diagnostics.EventLog class)

Date and Time Here (ASP.NET 4.0.30319.0): Event code: 100001
Event message: Authentication failure
Event time: Date and time
Event time (UTC): UTC date and time
// lots of information follows

I'm sure I'll never read those messages and writing them consumes some CPU time and IO bandwidth on the service VMs.

How do I get those failures not logged?


回答1:


This behavior is configured using <system.web><healthMonitoring> element in web.config. The default behavior is logging all unhandled exceptions and authentication failures to Application event log. There're two "rules" - one for the former and one for the latter.

So I just added this:

<healthMonitoring>
  <rules>
    <clear />
  </rules>
</healthMonitoring>

which made those default rules disappear and the problem is solved for me. Note that this also removes the rule for logging unhandled exceptions which I don't need either.



来源:https://stackoverflow.com/questions/23245519/how-do-i-prevent-asp-net-from-logging-authentication-failures

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!