I created the custom sentry sink inside my API project.
public class SentrySink : ILogEventSink {...}
I also created an extension method for my sink so that I can connect my sink through logging configuration.
public static LoggerConfiguration Sentry(this LoggerSinkConfiguration loggerConfiguration,
string dsn,
string release = null,
string environment = null,
LogEventLevel restrictedToMinimumLevel = LogEventLevel.Information,
IFormatProvider formatProvider = null)
{...}
When I use
Log.Logger = new LoggerConfiguration()
.ReadFrom.Configuration(configuration)
.WriteTo.Sentry(configuration["Sentry:Dsn"], restrictedToMinimumLevel: Serilog.Events.LogEventLevel.Error)
Everything works fine and log's are in sentry.
But when I set up the configuration in appsetting.json as
"WriteTo": [
{ "Name": "Sentry" }, ...
without defining config in LoggerConfiguration the log's are not sent to sentry.
Do I need to implement something more so that I can use configs from appsetting.json? Thanks.