title: Do not write logs to the database NLog + ASP .NET 5 + SQL Server
body: <p>My application is built on ASP .NET 5
  I used to do a project on .NET Core and everything was OK, there were no problems with logs. But in ASP.NET 5 I do not understand how to do this
  I'm trying to write logs to the database using this config:</p>
  
  <p><a href="https://github.com/nlog/NLog/wiki/Database-target#example-configurations" rel="nofollow noreferrer">https://github.com/nlog/NLog/wiki/Database-target#example-configurations</a></p>
  
  <p>This is my config file:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
  &lt;nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://www.nlog-project.org/schemas/NLog.xsd NLog.xsd"
        autoReload="true"
        throwExceptions="false"
        internalLogLevel="Off" internalLogFile="c:\temp\nlog-internal.log"&gt;
  
    &lt;!-- optional, add some variables
    https://github.com/nlog/NLog/wiki/Configuration-file#variables
    --&gt;
    &lt;variable name="myvar" value="myvalue"/&gt;
  
    &lt;!--
    See https://github.com/nlog/nlog/wiki/Configuration-file
    for information on customizing logging rules and outputs.
     --&gt;
    &lt;targets&gt;
    &lt;target name="database" xsi:type="Database"&gt;
  
      &lt;connectionStringName&gt;"Server=localhost\\SQLEXPRESS;Database=LocalDB;User ID=sa;Password=1234;"&lt;/connectionStringName&gt;
  
  
      &lt;commandText&gt;
        insert into dbo.LogExcelWorker (
        Application, Logged, Level, Message,
        Username,
        ServerName, Port, Url, Https,
        ServerAddress, RemoteAddress,
        Logger, CallSite, Exception
        ) values (
        @Application, @Logged, @Level, @Message,
        @Username,
        @ServerName, @Port, @Url, @Https,
        @ServerAddress, @RemoteAddress,
        @Logger, @Callsite, @Exception
        );
      &lt;/commandText&gt;
  
      &lt;parameter name="@application" layout="${appsetting:name=AppName:default=Unknown\: set AppName in appSettings}" /&gt;
      &lt;parameter name="@logged" layout="${date}" /&gt;
      &lt;parameter name="@level" layout="${level}" /&gt;
      &lt;parameter name="@message" layout="${message}" /&gt;
  
      &lt;parameter name="@username" layout="${identity}" /&gt;
  
      &lt;parameter name="@serverName" layout="${aspnet-request:serverVariable=SERVER_NAME}" /&gt;
      &lt;parameter name="@port" layout="${aspnet-request:serverVariable=SERVER_PORT}" /&gt;
      &lt;parameter name="@url" layout="${aspnet-request:serverVariable=HTTP_URL}" /&gt;
      &lt;parameter name="@https" layout="${when:inner=1:when='${aspnet-request:serverVariable=HTTPS}' == 'on'}${when:inner=0:when='${aspnet-request:serverVariable=HTTPS}' != 'on'}" /&gt;
  
      &lt;parameter name="@serverAddress" layout="${aspnet-request:serverVariable=LOCAL_ADDR}" /&gt;
      &lt;parameter name="@remoteAddress" layout="${aspnet-request:serverVariable=REMOTE_ADDR}:${aspnet-request:serverVariable=REMOTE_PORT}" /&gt;
  
      &lt;parameter name="@logger" layout="${logger}" /&gt;
      &lt;parameter name="@callSite" layout="${callsite}" /&gt;
      &lt;parameter name="@exception" layout="${exception:tostring}" /&gt;
    &lt;/target&gt;
  &lt;/targets&gt;
    &lt;rules&gt;
  
      &lt;logger name="*" minlevel="Debug" writeTo="database" /&gt; 
    &lt;/rules&gt;
  &lt;/nlog&gt;
  </code></pre>
  
  <p>I created the table in the database</p>
  
  <p>I try to make a test call of logs but nothing is written down:</p>
  
  <pre><code>    public string Index()
      {
          Logger log = LogManager.GetCurrentClassLogger();
          log.Trace( "trace message" );
          log.Debug( "debug message" );
          log.Info( "info message" );
          log.Warn( "warn message" );
          log.Error( "error message" );
          log.Fatal( "fatal message" );
  
          return "start...";
      }
  </code></pre>
  
  <p>But there are no records in the database</p>