Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sentry Serilog not creating issues in Sentry #1800

Closed
koffisani opened this issue Jul 22, 2022 · 11 comments
Closed

Sentry Serilog not creating issues in Sentry #1800

koffisani opened this issue Jul 22, 2022 · 11 comments
Labels
Bug Something isn't working Documentation Serilog

Comments

@koffisani
Copy link

Package

Sentry.Serilog

.NET Flavor

.NET Core

.NET Version

6.0.203

OS

Windows

SDK Version

3.19.0

Self-Hosted Sentry Version

21.8.0

Steps to Reproduce

  • Configure appsettings.json to work with Serilog

    {
            "Name": "Sentry",
            "Args": {
              "Dsn": "<DSN>",
              "MinimumBreadcrumbLevel": "Debug",
              "MinimumEventLevel": "Warning",
              "AttachStackTrace": true,
              "Debug": true,
              "MaxRequestBodySize": "always",
              "DiagnosticsLevel": "Info"
            }
          }
  • Create test event in code

     SentrySdk.CaptureException(new Exception("Test"));

Expected Result

I expect an issue to be created in Sentry

Actual Result

Unfortunately, in the logs, i get this :

Debug: Configuring the scope.
   Info: Capturing event.
  Debug: Running main event processor on: Event c3d7f61580f64f699b03cc2c019c9a17
  Debug: Creating SentryStackTrace. isCurrentStackTrace: True.
   Info: Envelope queued up: 'c3d7f61580f64f699b03cc2c019c9a17'
  Debug: Failed to report an error on a session because there is none active.
   Info: Capturing event.
  Debug: Running processor on exception: Test
  Debug: Creating SentryStackTrace. isCurrentStackTrace: False.
  Debug: Running main event processor on: Event 0ed7ccf536db49b2a6ee5ca07628358e
   Info: Envelope queued up: '0ed7ccf536db49b2a6ee5ca07628358e'
  Debug: Envelope c3d7f61580f64f699b03cc2c019c9a17 handed off to transport. #2 in queue.
  Debug: Envelope 'c3d7f61580f64f699b03cc2c019c9a17' sent successfully. Payload: {"sdk":{"name":"sentry.dotnet","version":"3.19.0"},"even
t_id":"c3d7f61580f64f699b03cc2c019c9a17"} {"type":"event","length":40195} {"modules":{"System.Private.CoreLib":"5.0.0.0","QrCode.Server":
"1.0.0.0","System.Runtime":"5.0.0.0","Microsoft.Extensions.Hosting.Abstractions":"5.0.0.0","netstandard":"2.1.0.0","System.ComponentModel
":"5.0.0.0","Microsoft.Extensions.DependencyInjection.Abstractions":"5.0.0.0","QrCode.Infrastructure":"1.0.0.0","Microsoft.AspNetCore.Ide
ntity.EntityFrameworkCore":"5.0.7.0","Microsoft.EntityFrameworkCore":"5.0.7.0","Microsoft.Extensions.Identity.Stores":"5.0.0.0","QrCode.A
pplication":"1.0.0.0","QrCode.Domain":"1.0.0.0","Microsoft.EntityFrameworkCore.SqlServer":"5.0.7.0","Microsoft.EntityFrameworkCore.Relati
onal":"5.0.7.0","Microsoft.Extensions.Logging.Abstractions":"5.0.0.0","Microsoft.Extensions.Hosting":"5.0.0.0","Microsoft.AspNetCore.Host
ing.Abstractions":"5.0.0.0"
...
@mattjohnsonpint
Copy link
Contributor

Thanks for the bug report. We'll see if we can reproduce your results and get back to you asap. Thanks.

@mattjohnsonpint
Copy link
Contributor

FWIW, the log you gave here is showing the error event being sent successfully. It should have appeared in Sentry.

@mattjohnsonpint mattjohnsonpint moved this from Needs Discussion to Needs Investigation in Mobile & Cross Platform SDK Jul 26, 2022
@ReneGreen27
Copy link
Member

Do we have an update here @mattjohnsonpint? Thanks!

@mattjohnsonpint
Copy link
Contributor

I was unable to find any bug that I could reproduce, however I think I can explain the situation.

@koffisani - It looks like you are using Sentry with Serilog in ASP.NET Core, and doing all of your configuration in appsettings.json. In that case, the majority of your Sentry configuration needs to be in the Sentry section, while only the options specific for Serilog should be in Serilog section. In other words, the configuration file should look similar to this:

{
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft.AspNetCore": "Warning"
    }
  },
  "AllowedHosts": "*",
  "Serilog": {
    "MinimumLevel": "Information",
    "Override": {
      "Microsoft.AspNetCore": "Information"
    },
    "WriteTo": [
      {
        "Name": "Console"
      },
      {
        "Name": "Sentry",
        "Args": {
          "MinimumBreadcrumbLevel": "Debug",
          "MinimumEventLevel": "Warning"
        }
      }
    ]
  },
  "Sentry": {
    "Dsn": "<Your DSN>",
    "AttachStackTrace": true,
    "Debug": true,
    "MaxRequestBodySize": "always",
    "DiagnosticsLevel": "Info"
  }
}

Please give that a try and let me know if it works or not.

Note, that we've seen this before with #1223 and #1137. Ultimately we need to update our docs and samples to resolve this.

@mattjohnsonpint mattjohnsonpint added Documentation and removed Bug Something isn't working labels Jul 26, 2022
@mattjohnsonpint mattjohnsonpint moved this from Needs Investigation to Backlog in Mobile & Cross Platform SDK Jul 26, 2022
@mattjohnsonpint mattjohnsonpint added the Bug Something isn't working label Jul 27, 2022
@koffisani
Copy link
Author

Thank you @mattjohnsonpint for your support. In case it's usefull, I'm using BlazorHero's Clean Architecture template.

I've changed my server's appsettings.json file as per your comment, but I can not any issue created in Sentry. I can realise that there's no more debug info concerning Sentry.

@williycole
Copy link

Without going into to much detail and hijacking I can confirm I am having a very similar issue with .net6/sentry/serilog. Tried setting this up at work for a few hours the other day the .net 6 way until I found this open issue.

@SimonCropp
Copy link
Contributor

@ReneGreen27 @koffisani @williycole i had a go a reproducing this https://github.com/SimonCropp/SentryAspCoreSerilogRepro/tree/UsingAppConfig

and it correctly logs an issue to Sentry
image

perhaps one of you could help me modify that sample in a way that causes the issue?

Note you will need to change the DSN in config if you want to experiment locally

@SimonCropp
Copy link
Contributor

@ReneGreen27 @koffisani @williycole gentle nudge

@koffisani
Copy link
Author

Thank you, @SimonCropp for your support.

I just reproduce your code here locally. And everytime I refresh the web page, I get this in my docker logs :

<client_IP> - - [25/Aug/2022:12:00:23 +0000] "POST /api/7/envelope/ HTTP/1.1" 200 41 "-" "-" "-"
<client_IP> - - [25/Aug/2022:12:00:23 +0000] "POST /api/7/envelope/ HTTP/1.1" 200 41 "-" "-" "-"
<client_IP> - - [25/Aug/2022:12:00:23 +0000] "POST /api/7/envelope/ HTTP/1.1" 200 41 "-" "-" "-"
<client_IP> - - [25/Aug/2022:12:00:23 +0000] "POST /api/7/envelope/ HTTP/1.1" 200 41 "-" "-" "-"

and in the log, I can see this

[12:00:36 ERR] Logging using static Serilog directly also goes to Sentry.
[12:00:36 DBG] Connection id "0HMK6I5DT9TPP" completed keep alive response.
[12:00:36 INF] Request finished HTTP/1.1 GET http://localhost:5002/favicon.ico - - - 200 0 - 15.4105ms
[12:01:25 DBG] Connection id "0HMK6I5DT9TPQ" received FIN.
[12:01:25 DBG] Connection id "0HMK6I5DT9TPQ" sending FIN because: "The client closed the connection."
[12:01:25 DBG] Connection id "0HMK6I5DT9TPQ" disconnecting.
[12:01:25 DBG] Connection id "0HMK6I5DT9TPQ" stopped.
[12:02:47 DBG] Connection id "0HMK6I5DT9TPP" disconnecting.
[12:02:47 DBG] Connection id "0HMK6I5DT9TPP" stopped.
[12:02:47 DBG] Connection id "0HMK6I5DT9TPP" sending FIN because: "The Socket transport's send loop completed gracefully."

Hope this helps identify my issue.

@williycole
Copy link

williycole commented Aug 25, 2022

Thanks for looking into this @SimonCropp. I had to punt this issue at work for a later date. Didn't want to hijack the thread but I can add a bit more clarity to my issue until I can get back around to this one.

My issue is not "Sentry Serilog not creating issues in Sentry". I was able follow sentry docs and get logs working but only for production env. I set up general appsettings, appsettings.Development.json, appsettings.Production.json etc...,
each using their different corresponding dsn's from sentry but no matter what couldn't get anything logging outside of prod env prodenv.
Hopefully that adds some clarity, if the bug is still open when I can get back around to this I'll give it another go bring more details here you.

@bitsandfoxes
Copy link
Contributor

There've been changes and updates to our Serilog integration, specifically with the way the integration can initialize the SDK. Please feel free to reply or reopen this issue if it persists for you in the current version of the SDK.

@github-project-automation github-project-automation bot moved this from Backlog to Done in Mobile & Cross Platform SDK Jul 8, 2024
@github-project-automation github-project-automation bot moved this to Done in GDX Jul 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working Documentation Serilog
Projects
Status: Done
Archived in project
Development

No branches or pull requests

6 participants