在SQL Server
中设置应用程序以使用镜像数据库。我与DB的连接字符串如下所示:
Data Source=svrDBPrinciple;Failover Partner=svrDBMirror;
但是,将相同的内容放入NLog
连接字符串中,使用与功能数据库连接相同的安全性详细信息会导致"用户登录失败"错误。
可以配置NLog使用自动故障转移吗?
编辑 - 要求配置文件:
<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
throwExceptions="true"
internalLogFile="[a path]\internal_log_file.txt"
internalLogLevel="Trace"
internalLogToConsole="true">
<targets>
<target xsi:type="Database" name="database"
dbProvider="System.Data.SqlClient"
connectionString="Data Source=svrDBPrinciple;Failover Partner=svrDBMirror;Initial Catalog=[catalogue];User ID=[id];Password=[pwd];">
<commandText>
INSERT INTO [Logging] ([LogDate], [Severity], [Message], [Source], [Exception], [Inner])
VALUES( @date, @severity, @message, @source, @exception, @inner)
</commandText>
<parameter name="@date" layout="${date}"/>
<parameter name="@severity" layout="${level}"/>
<parameter name="@message" layout="${message}"/>
<parameter name="@source" layout="${logger} ${callsite}"/>
<parameter name="@exception" layout="${exception:format=tostring}"/>
<parameter name="@inner" layout="${exception:innerFormat=tostring}" />
</target>
<target name="file"
type="File"
fileName="[a path and filename]_${shortdate}.log"
layout="${longdate} ${logger} ${message} ${exception:format=Message, Type, ShortType, ToString, Method, StackTrace:separator=, }"/>
</targets>
<rules>
<logger name="*" levels="Trace, Debug, Fatal, Error, Warn, Info" writeTo="file" />
<logger name="*" levels="Trace, Debug, Fatal, Error, Warn, Info" writeTo="database" />
</rules>
</nlog>
所以我不得不断定NLog必须与镜像数据库进行不同的标准SQL Server连接字符串交互?