mvc3中的健康监测

时间:2012-06-26 11:10:32

标签: sql-server asp.net-mvc-3

我想在mvc3应用程序中进行健康监控。

我正在使用eventviewer。但我想将这些事件和错误保存到Sql server数据库中。

<healthMonitoring enabled="true"  heartbeatInterval="10">
       <providers>
    <clear/>
    <add name="EventLogProvider" type="System.Web.Management.EventLogWebEventProvider,System.Web,Version=4.0.0.0,Culture=neutral,PublicKeyToken=b03f5f7f11d50a3a" />

    <add connectionStringName="LocalSqlServer" maxEventDetailsLength="1073741823"
        buffer="false" bufferMode="Notification" name="SqlWebEventProviderlane"
        type="System.Web.Management.SqlWebEventProvider,System.Web,Version=4.0.0.0,Culture=neutral,PublicKeyToken=b03f5f7f11d50a3a" />

  </providers>

  <profiles>
    <add name="Default" minInstances="1" maxLimit="Infinite" minInterval="00:01:00"
                custom="" />
            <add name="Critical" minInstances="1" maxLimit="Infinite" minInterval="00:00:00"
                custom="" />
  </profiles>

  <rules>
    <clear/>

    <add name="All Errors Default" eventName="All Events" provider="EventLogProvider"
        profile="Default" minInstances="1" maxLimit="Infinite" minInterval="00:01:00"
        custom="" />
    <add name="Failure Audits Default" eventName="Failure Audits"
        provider="EventLogProvider" profile="Default" minInstances="1"
        maxLimit="Infinite" minInterval="00:01:00" custom="" />
  </rules>

  <eventMappings>
    <clear/>
    <add name="All Events" type="System.Web.Management.WebBaseEvent,System.Web,Version=4.0.0.0,Culture=neutral,PublicKeyToken=b03f5f7f11d50a3a"
          startEventCode="0" endEventCode="2147483647" />
          <add name="All Errors" type="System.Web.Management.WebBaseErrorEvent,System.Web,Version=4.0.0.0,Culture=neutral,PublicKeyToken=b03f5f7f11d50a3a"
        startEventCode="0" endEventCode="2147483647" />
         </eventMappings>

</healthMonitoring>

怎么做?

1 个答案:

答案 0 :(得分:0)

在规则部分中,您必须引用名为“SqlWebEventProviderlane”的提供程序:

<add name="All Errors Default" eventName="All Events" provider="SqlWebEventProviderlane" 
    profile="Default" minInstances="1" maxLimit="Infinite" minInterval="00:01:00" 
    custom="" /> 

然后,您必须在该部分中提供名为“LocalSqlServer”的连接字符串,该字符串指向您的数据库。

<connectionStrings>
  <add name="LocalSqlServer" connectionString="data source=serverName;initial catalog=yourDataBase;..."/>
</connectionStrings>

您必须使用aspnet_regsql工具准备数据库。