To use the Exceptionless sink, first install the NuGet package:
Install-Package Serilog.Sinks.Exceptionless
Next, we need to ensure that Exceptionless is configured with an API Key. If you are already using Exceptionless you can skip this step.
The Exceptionless sink will use the default ExceptionlessClient
client instance. This ensures
that all of your Exceptionless configuration is shared with the sink and also enables logging
of unhandled exceptions to Exceptionless.
For advanced users who wish to configure the sink to use custom
ExceptionlessClient
instance you can provide an API Key orExceptionlessClient
instance toWriteTo.Exceptionless()
.
using Exceptionless;
ExceptionlessClient.Default.Startup("API_KEY");
Next, enable the sink using WriteTo.Exceptionless()
Log.Logger = new LoggerConfiguration()
.WriteTo.Exceptionless(b => b.AddTags("Serilog Example"))
.CreateLogger();
To get tags to populate on the exceptionless UI, add a Tags
string enumerable to any log.
using var _ = _logger.BeginScope(new Dictionary<string, object> { ["Tags"] = new string[] { "Tag1", "Tag2" }});
_logger.Log(logLevel, eventId, state, exception, formatter);
Copyright © 2023 Serilog Contributors - Provided under the Apache License, Version 2.0.