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.

Sentry.Serilog doesn't log Environment

See original GitHub issue

Please mark the type framework used:

  • ASP.NET MVC
  • ASP.NET Web API (OWIN)
  • ASP.NET Core
  • WPF
  • WinForms
  • Xamarin
  • Other:

Please mark the type of the runtime used:

  • .NET Framework
  • Mono
  • .NET Core
  • Version: 2.2.0

Please mark the NuGet packages used:

  • Sentry
  • Sentry.Serilog
  • Sentry.NLog
  • Sentry.Log4Net
  • Sentry.Extensions.Logging
  • Sentry.AspNetCore

Please describe the the steps to reproduce the issue or link to a repository with a small reproducible code.

Currently we use Sentry.Serilog 1.2.0, and it does not correctly display Environment, it always displays “All Environments”. We have “ASPNETCORE_ENVIRONMENT” set in the environment variables. We also use Serilog to distribute our logging, and have it configured with the config listed below.

Note: We dont use Sentry.AspNetCore for 2 reasons, 1 our console applications don’t use AspNetCore it just uses NetCore, and 2 we use Serilog to enrich data meta data and to distribute our logging.

Also note, I changed the key below for security purposes.

  "Serilog": {
    "MinimumLevel": {
      "Default": "Information",
      "Override": {
        "Microsoft": "Warning",
        "System": "Warning"
      }
    },
    "WriteTo": [
      { "Name": "LiterateConsole" },
      {
        "Name": "Logentries",
        "Args": {
          "token": "99b37aaf-c472-40f7-a50f-5ab3d457f071-123",
          "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level:u3}] [{MachineName}] [{SourceContext}] {Message:lj}{NewLine}{Exception}"
        }
      },
      {
        "Name": "Sentry",
        "Args": {
          "MinimumBreadcrumbLevel": "Information",
          "MinimumEventLevel": "Error",
          "Dsn": "https://a16b8602ba8e46a49188c7de65af9072123@sentry.io/202852123",
          "AttachStacktrace": true,
          "SendDefaultPii": false
        }
      }
    ]
  }

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:11 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
AjaySewradjcommented, Mar 19, 2020

@rmsy

I fixed it by implementing the following workaround in the main function of the webapp/service:

var environment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") ?? "Production";
Environment.SetEnvironmentVariable("SENTRY_ENVIRONMENT", environment);
0reactions
JimHumecommented, Mar 31, 2020

Ah, perfect–thanks @bruno-garcia !

Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshooting for Serilog
Set the environment variable SENTRY_KEEP_LARGE_ENVELOPE_PATH to the directory you want these to be written to. Make sure the process the SDK is running...
Read more >
Serilog not logging to Sentry levels different than Error
1 Answer. By default, the Sentry Serilog integration only sends events for log level Error or higher. For Info logs, the SDK keeps...
Read more >
Logging in .NET Core and ASP.NET Core
Log level can be set by any of the configuration providers. The : separator doesn't work with environment variable hierarchical keys on all ......
Read more >
Sentry.Serilog 3.0.0-alpha.9
Official Serilog integration for Sentry - Open-source error tracking that helps developers monitor and fix crashes in real time.
Read more >
Integrating Sentry with ASP.NET Core - YouTube
Quick demo on how to integrate the new (preview) SDK of Sentry. ... How Structured Logging With Serilog Can Make Your Life Easier....
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