My logs are not inserted into database.But logs are stored in file succesfully.
Here is my 'nlog.cofig"
<?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">
<targets>
<target xsi:type="File" name ="allfile" fileName="D:\Playground\asp_net\AspdotnetCore\internal-nlog.txt"/>
<extensions>
<add assembly="NLog.Web.AspNetCore"/>
<add assembly="NLog.Appsettings.Standard"/>
</extensions>
<target name="database" xsi:type="Database" keepConnection="true" useTransactions="true"
dbProvider="System.Data.SqlClient"
connectionString="data source=localhost;initial catalog=EmployeeDB;integrated security=false;persist security info=True;Trusted_Connection=True;"
commandText="INSERT INTO Logs(EventDateTime, EventLevel, UserName, MachineName, EventMessage, Filename, ErrorClass, ErrorMethod, ErrorMessage, InnerErrorMessage) VALUES (@EventDateTime, @EventLevel, @UserName, @MachineName, @EventMessage, @Filename, @ErrorClass, @ErrorMethod, @ErrorMessage, @InnerErrorMessage)">
<parameter name="@EventDateTime" layout="${date:s}" />
<parameter name="@EventLevel" layout="${level}" />
<parameter name="@UserName" layout="${identity}" />
<parameter name="@MachineName" layout="${machinename}" />
<parameter name="@EventMessage" layout="${message}" />
<parameter name="@Filename" layout="${callsite:filename=true}" />
<parameter name="@ErrorClass" layout="${callsite:class=true}" />
<parameter name="@ErrorMethod" layout="${callsite:method=true}" />
<parameter name="@ErrorMessage" layout="${exception}" />
<parameter name="@InnerErrorMessage" layout="${stacktrace}" />
</target>
</targets>
<rules>
<logger name="database" minlevel="Trace" writeTo="database" />
<logger name ="file" minlevel="Trace" writeTo="allfile"></logger>
</rules>
</nlog>