Sentry - Configuring it to log all errors
# help-with-umbraco
s
Has anyone configured Sentry to work with Umbraco v10+? I'll like to just hook all _logger.Logxxxx() calls. https://docs.sentry.io/platforms/dotnet/guides/serilog/ I think I'm right in thinking I should use the serilog extension. I tried added the following to my startup.cs Configure method... it builds and runs but nothing is logging to Sentry.
Copy code
Log.Logger = new LoggerConfiguration()
   .WriteTo.Sentry(o =>
   {
       o.Environment = _config["Sentry:Environment"];
       o.Dsn = _config["Sentry:Dsn"];
       // Debug and higher are stored as breadcrumbs (default is Information)
       o.MinimumBreadcrumbLevel = (LogEventLevel) Enum.Parse(typeof(LogEventLevel), _config["Sentry:MinimumBreadcrumbLevel"]);
       // Warning and higher is sent as event (default is Error)
       o.MinimumEventLevel = (LogEventLevel) Enum.Parse(typeof(LogEventLevel), _config["Sentry:MinimumEventLevel"]);
   })
 .CreateLogger();
b
@SiempreSteve umbraco using static logger internally so it will get overriden, you should use configuration in appsettings with this package: https://github.com/serilog/serilog-settings-configuration
s
Forgive my ignorance. I already have a Serilog section in the appsettings. So what does this do? How does this "point" the logs to Sentry's online service? Do I need to add a "WriteTo"
b
So this allows you to configure sinks, without touching the static logger, in your case you will need add WriteTo, and setup sentry inside of this configuration, sadly you will not be able to reference other part of configuration
s
I don't understand how this is working. But it is. thanks!
b
@SiempreSteve umbraco is looping through writeTo and adding them to Serilog Sink collection 🙂
s
I understand all of those words. 😂
b
I can link you later to each of solution code lines 😂 but not sure if you are up for it
s
I am really not. But I very much appreciate your help and for getting it working.
56 Views