How to registry sentry using Autofac in a MVC5 / WebApi dotnet project (NOT CORE)

I’m having trouble getting sentry to work in a .net 4.7.2 webapi project using autofac and serilog.

I’ve tried a million things, but sentry just refuses to log anything from serilog, despite every other serilog sink working fine… I just get “an error occurred writing the event” from the diagnostic log…

Can someone help with how I should be registering sentry with autofac so that it works with serilog which is also registered with autofac?

(I’m not using sentry directly…just as a serilog sink…)

You can register like:
container.Register<ISentryClient, HubAdapter.Instance>().SingletonLifetime();
container.Register<IHub, HubAdapter.Instance>().SingletonLifetime();

You can take via constructor injection a ISentryClient if all your need is CaptureX methods.
If you need scope management (set data that hangs around in case an event is send down the road) then take in IHub which offer ConfigureScope and friends.

In any case you still need to initialize the SDK via SentrySdk.Init. You can do that on Global.asax on Application_Start and make sure to Dispose of the returned IDisposable on Application_Stop to make sure queued up events are flushed to sentry before the apps terminates.

Thanks bruno, but that is how to register sentry if you are using it directly.
I’m not.
I’m using it as a serilog sink ONLY.
I have no code using ISentryClient, or IHub. No controllers log to sentry - just serilog.
Also, I don’t have a global.asax as I’m using OWIN startup.