我正在使用Nlog进行错误登录。我在web.config中使用以下代码配置了Nlog,但程序抛出错误"无法找到请求的.Net Framework数据提供程序。它可能没有安装。"
<nlog xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" throwExceptions="true" internalLogFile="c:\nlog.txt" internalLogLevel="Debug">
<extensions>
<add assembly="NLog.Extended" />
</extensions>
<targets>
<target name="Console" xsi:type="Console" layout="${level:uppercase=true} ${message}"/>
<target name="DelivrosLogFile" xsi:type="File" fileName="C:\DelivrosLogs\Delivros.log" layout="${longdate} |${message}| ${stacktrace}"/>
<target xsi:type="Database" name="DelivrosDatabaseLogging" connectionStringName="DelivrosEntities"
commandText="INSERT INTO tbl_ErrorLogIn( Event_ID,Priority,Severity,Title,Timestamp,MachineName,AppDomainName,PocessID,ProcessName,ThreadName,Win32ThreadId,Message,FormattedMessage) VALUES (@Event_ID,@Priority,@Severity,@Title,@Timestamp,@MachineName,@AppDomainName,@PocessID,@ProcessName,@ThreadName,@Win32ThreadId,@Message,@FormattedMessage)">
<parameter name="@Event_ID" layout="0"/>
<parameter name="@Priority" layout="3"/>
<parameter name="@Severity" layout="${level}"/>
<parameter name="@Title" layout="Journal API"/>
<parameter name="@Timestamp" layout="${date}"/>
<parameter name="@MachineName" layout="${machinename}"/>
<parameter name="@AppDomainName" layout="Journal API"/>
<parameter name="@PocessID" layout="${processid}"/>
<parameter name="@ProcessName" layout="${processname}"/>
<parameter name="@ThreadName" layout="${threadname}"/>
<parameter name="@Win32ThreadId" layout="${threadid}"/>
<parameter name="@Message" layout="${exception}"/>
<parameter name="@FormattedMessage" layout="${message} "/>
</target>
</targets>
<rules>
<logger name="*" levels="Info,Warn,Error,Fatal" writeTo="Console"/>
<logger name="*" levels="Info,Warn,Fatal" writeTo="DelivrosLogFile"/>
<logger name="*" levels="Error" writeTo="DelivrosDatabaseLogging"/>
</rules>
我坚持了四天......那里有谁能帮助我......
答案 0 :(得分:1)
给出了providerName =&#34; System.Data.EntityClient&#34;在连接字符串中,我将其更改为providerName =&#34; System.Data.SqlClient&#34;
答案 1 :(得分:0)
我可以补充说,如果您已经使用过EntityFramework,则不能简单地更改连接字符串中的提供程序,因为您的实体将无法正常工作。您可以使用providerName =“System.Data.SqlClient”为错误记录添加另一个连接字符串。