这是我的nlog.config文件.我已经打开了throwsException.
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" throwExceptions="true"> <targets> <target type="Database" name="databaseLog" dbProvider="sqlserver" connectionstring="server=.\sqlExpress;database=Movie;integrated security=true"> <commandText> INSERT INTO [Log] ([Description],[Level] ) VALUES (@Description,@Level ) </commandText> <parameter name="@Description" layout="${message}"/> <parameter name="@Level" layout="${level}"/> </target> </targets> <rules> <logger name="*" minLevel="Trace" appendTo="databaseLog"/> </rules> </nlog>
这将工作并将记录插入数据库.但是我想使用connectionstringName而不是重新键入connectionstring.
当我将connectionstring更改为connectionstringname时,这样….
connectionstring="server=.\sqlExpress;database=Movie;integrated security=true"
至
connectionStringName="ApplicationConnectionString"
我收到一个错误
期望’providerInvariantName’参数的非空字符串