here is my nlog.config file. I have turned on the 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>
This will work and will insert records into the database. However I would like to use connectionstringName and not retype the connectionstring. When I change the connectionstring to connectionstringname like this....
connectionstring="server=.\SQLExpress;database=Movie;integrated security=true"
to
connectionStringName="ApplicationConnectionString"
I get an error Expecting non-empty string for 'providerInvariantName' parameter
Add System.Data.SqlClient
to attribute ProviderName
in your connection string in web.config/app.config:
<add name="ApplicationConnectionString"
providerName="System.Data.SqlClient"
connectionString="server=.\SQLExpress;database=Movie;integrated security=true;"/>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With