đây là tệp nlog.config của tôi. Tôi đã bật throwsException.làm tắc nghẽn bằng cách sử dụng connectionStringName để ghi nhật ký cơ sở dữ liệu
<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>
này sẽ làm việc và sẽ chèn các bản ghi vào cơ sở dữ liệu. Tuy nhiên tôi muốn sử dụng connectionstringName và không gõ lại chuỗi kết nối. Khi tôi thay đổi connectionstring để connectionstringname như thế này ....
connectionstring="server=.\SQLExpress;database=Movie;integrated security=true"
để
connectionStringName="ApplicationConnectionString"
tôi nhận được một lỗi Mong chuỗi không trống cho 'providerInvariantName 'tham số
Cảm ơn Nick! làm việc tuyệt vời – eiu165
Bạn có thể vui lòng làm rõ nơi này đi nLog config hoặc web.config? Cảm ơn. – AlexVPerl