question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

WriteTo.MSSqlServer to .net Core 2.1 not working

See original GitHub issue

I am having problem while trying to set the configurations via C # by .WriteTo.MSSqlServer does not work! Just when I do .ReadFrom.Configuration(Configuration) works.

ASP.NET MVC Core 2.1 Project image

            var logDB = settings.ConnectionString.AuditoriaConnection;
            var logTable = "LogError";
            var options = new ColumnOptions();
            options.Store.Add(StandardColumn.LogEvent);
            options.LogEvent.DataLength = 2048;
            options.PrimaryKey = options.TimeStamp;
            options.TimeStamp.NonClusteredIndex = true;

            Log.Logger = new LoggerConfiguration()
                .WriteTo.MSSqlServer( 
                    connectionString: logDB,
                    tableName: logTable,
                    columnOptions: options,
                    appConfiguration: Configuration)
                .CreateLogger();

also tried without the appConfiguration: Configuration), direct: .WriteTo.MSSqlServer (logDB, logTable)

My appsetting.json

"Serilog": {
    "MinimumLevel": "Information",
    "WriteTo": [
      {
        "Name": "MSSqlServer",
        "Args": {
          "connectionString": "Data Source=xxx.yyy.zzz",
          "tableName": "LogError",
          "autoCreateSqlTable": true,
          "restrictedToMinimumLevel": "Information ", //https://github.com/serilog/serilog/wiki/Writing-Log-Events
          "columnOptionsSection": {
            "customColumns": [
              {
                "ColumnName": "SetorErro",
                "DataType": "int",
                "AllowNull": true
              },
              {
                "ColumnName": "LocalErro",
                "DataType": "nvarchar",
                "DataLength": 150,
                "AllowNull": true
              }
            ]
          }
        }
      }
    ]
  }

symptom: it does not create the table and consequently does not write any log

only works via app setting.json if trying via code does not work if it makes hybrid worse yet.

I have read all the documentation, including doing exactly as recommended and nothing https://github.com/serilog/serilog-sinks-mssqlserver#code-only-any-net-target

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
skorubacommented, Feb 9, 2019

I have some issue - any help please? Thanks!

0reactions
ckadlubacommented, Dec 16, 2020

Since this report is quite old and we have rewritten a lot of the code in the meantime, I encourage everyone to update to the newest version of the sink. Perhaps the problem is gone, because there were no reports of this for a long time. If the problem reappears with the latest version, pleas open a new but.

I’m closing this issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

WriteTo.MSSqlServer to .net Core 2.1 not working #185
I am having problem while trying to set the configurations via C # by .WriteTo.MSSqlServer does not work! Just when I do .ReadFrom....
Read more >
Serilog.Sinks.MsSqlServer not working with ASP.NET Core ...
Discovered the issue was with the version of Serilog.Sinks.MsSqlServer. Using the latest dev version uses the json configuration correctly.
Read more >
Serilog.Sinks.MsSqlServer stops writing to database
Hi I'm using: Asp.Net Core 2.2.0 Serilog.sinks.datadog.logs 0.3.4 ... Information()/Error() statements are not written to database & Datadog.
Read more >
Asp.Net Core 2 Logging With Serilog And Microsoft SQL ...
In this post, I'm going to describe how we can configure Serilog with Asp.Net Core 2 web and Api projects. I also configure...
Read more >
ASP.Net Core 2.1 Serilog SQL Server Sink using Azure SQL is ...
Coding example for the question ASP.Net Core 2.1 Serilog SQL Server Sink using Azure SQL is working locally but not from Azure app...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found