Serilog.Sinks.Raygun
7.4.0-pre-1
See the version list below for details.
dotnet add package Serilog.Sinks.Raygun --version 7.4.0-pre-1
NuGet\Install-Package Serilog.Sinks.Raygun -Version 7.4.0-pre-1
<PackageReference Include="Serilog.Sinks.Raygun" Version="7.4.0-pre-1" />
paket add Serilog.Sinks.Raygun --version 7.4.0-pre-1
#r "nuget: Serilog.Sinks.Raygun, 7.4.0-pre-1"
// Install Serilog.Sinks.Raygun as a Cake Addin #addin nuget:?package=Serilog.Sinks.Raygun&version=7.4.0-pre-1&prerelease // Install Serilog.Sinks.Raygun as a Cake Tool #tool nuget:?package=Serilog.Sinks.Raygun&version=7.4.0-pre-1&prerelease
serilog-sinks-raygun
Serilog Sinks error and performance monitoring with Raygun is available using the serilog-sinks-raygun provider.
serilog-sinks-raygun is a library that you can easily add to your website or web application, which will then monitor your application and display all Serilog errors and issues affecting your users within your Raygun account. Installation is painless.
The provider is a single package (Serilog.Sinks.Raygun) which includes the sole dependency (Serilog), allowing you to drop it straight in.
Getting started
Step 1 - Add packages
Install the Serilog (if not included already) and Serilog.Sinks.Raygun package into your project. You can either use the below dotnet CLI command, or the NuGet management GUI in the IDE you use.
dotnet add package Serilog
dotnet add package Serilog.Sinks.Raygun
Step 2 - Initialization
There are two recommended options for initializing the Raygun Serilog Sink. Which option is best to use depends on the application.
Option 1 - Using logger configuration
You can initialize Raygun's Serilog Sink through a Logger Configuration. This should be done inside of the main entry point of your application - for instance, Program.Main(), Global.asax, Application_Start Etc. The exact entry point will differ between frameworks.
Minimum setup example:
Log.Logger = new LoggerConfiguration()
.MinimumLevel.Verbose()
.WriteTo.Raygun("paste_your_api_key_here")
.CreateLogger();
Example setup with optional properties:
Log.Logger = new LoggerConfiguration()
.MinimumLevel.Verbose()
.WriteTo.Raygun("paste_your_api_key_here",
ListOfWrapperExceptions,
"CustomUserNameProperty",
"CustomAppVersionProperty",
LogEventLevel.Information,
CustomFormatProvider,
new[] { "globalTag1", "globalTag2" },
new[] { "ignoreField1", "ignoreField2" },
"CustomGroupKeyProperty",
"CustomTagsProperty",
"CustomUserInfoProperty",
onBeforeSendArguments => { /*OnBeforeSend: Action<onBeforeSendArguments>*/ })
.CreateLogger();
Option 2 - Using the JSON configuration file
You can initialize Raygun's Serilog Sink inside a Serilog JSON configuration file using the following examples.
Minimum setup example:
{
"Serilog": {
"Using": [
"Serilog.Sinks.Raygun"
],
"WriteTo": [
{
"Name": "Raygun",
"Args": {
"applicationKey": "paste_your_api_key_here"
}
}
]
}
}
Example setup with optional properties:
{
"Serilog": {
"Using": [
"Serilog.Sinks.Raygun"
],
"WriteTo": [
{
"Name": "Raygun",
"Args": {
"applicationKey": "paste_your_api_key_here",
"userNameProperty": "CustomUserNameProperty",
"applicationVersionProperty": "CustomAppVersionProperty",
"restrictedToMinimumLevel": "Error",
"ignoredFormFieldNames": ["ignoreField1", "ignoreField2"],
"tags": ["globalTag1", "globalTag2"],
"groupKeyProperty": "CustomGroupKeyProperty",
"tagsProperty": "CustomTagsProperty",
"userInfoProperty": "CustomUserInfoProperty"
}
}
]
}
}
Configuration Properties
applicationKey
type: string
required
Each application you create in Raygun will have an API key which you can pass in here to specify where the crash reports will be sent to. Although this is required, you can set this to null or empty string which would result in crash reports not being sent. This can be useful if you want to configure your local environment to not send crash reports to Raygun and then use config transforms or the like to provide an API key for other environments.
wrapperExceptions
type: IEnumerable<Type>
default: null
This is a list of wrapper exception types that you're not interested in logging to Raygun. Whenever an undesired wrapper exception is logged, it will be discarded and only the inner exception(s) will be logged.
For example, you may not be interested in the details of an AggregateException, so you could include typeof(AggregateException)
in this list of wrapperExceptions. All inner exceptions of any logged AggregateException would then be sent to Raygun as separate crash reports.
userNameProperty
type: string
default: UserName
This is so you can specify the username to log the information as a part of the crash report. By default it is UserName. You can set this to be to null
if you do not want to use this feature.
Log.ForContext("CustomUserNameProperty", "John Doe").Error(new Exception("random error"), "other information");
applicationVersionProperty
type: string
default: ApplicationVersion
By default, crash reports sent to Raygun will have an ApplicationVersion field based on the version of the entry assembly for your application. If this is not being picked up correctly, or if you want to provide a different version, then you can do so by including the desired value in the logging properties collection.
You can specify the property key that you place the version in by using this applicationVersionProperty
setting. Otherwise the version will be read from the "ApplicationVersion" key.
Log.ForContext("CustomAppVersionProperty", "1.2.11").Error(new Exception("random error"), "other information");
restrictedToMinimumLevel
type: LogEventLevel
default: LogEventLevel.Error
You can set the minimum log event level required in order to write an event to the sink. By default, this is set to Error as Raygun is mostly used for error reporting.
formatProvider
type: IFormatProvider
default: null
This property supplies culture-specific formatting information. By default, it is null.
tags
type: IEnumerable<string>
default: null
This is a list of global tags that will be included on every crash report sent with this Serilog sink.
ignoredFormFieldNames
type: IEnumerable<string>
default: null
Crash reports sent to Raygun from this Serilog sink will include HTTP context details if present. (Currently only supported in .NET Framework applications). This option lets you specify a list of form fields that you do not want to be sent to Raygun.
Setting ignoredFormFieldNames
to a list that only contains "*" will cause no form fields to be sent to Raygun. Placing * before, after or at both ends of an entry will perform an ends-with, starts-with or contains operation respectively.
Note that HTTP headers, query parameters, cookies, server variables and raw request data can also be filtered out. Configuration to do so is described in the RaygunSettings section further below.
The ignoreFormFieldNames
entries will also strip out specified values from the raw request payload if it is multipart/form-data.
groupKeyProperty
type: string
default: GroupKey
Crash reports sent to Raygun will be automatically grouped together based on stack trace and exception type information. The groupKeyProperty
setting specifies a key in the logging properties collection where you can provide a grouping key. Crash reports containing a grouping key will not be grouped automatically by Raygun. Instead, crash reports with matching custom grouping keys will be grouped together.
Log.ForContext("CustomGroupKeyProperty", "TransactionId-12345").Error(new Exception("random error"), "other information");
tagsProperty
type: string
default: Tags
This allows you to specify a key in the properties collection that contains a list of tags to include on crash reports. Note that these will be included in addition to any global tags described above. If you set a list of tags in the properties collection multiple times (e.g. at different logging scopes) then only the latest list of tags will be used.
Log.ForContext("CustomTagsProperty", new[] {"tag1", "tag2"}).Error(new Exception("random error"), "other information");
Log.Error(new Exception("random error"), "other information {@CustomTagsProperty}", new[] {"tag3", "tag4"});
userInfoProperty
type: string
default: null
This is null by default, so you need to configure the userInfoProperty
name if you want to log more user information in this way. This will cause the provided RaygunIdentifierMessage to be included in the "User" section of the Raygun payload, allowing the information to be picked up by the "Users" section of the Raygun service. It's recommended to destructure the RaygunIdentifierMessage, but this feature will still work if you don't. Sending user information in this way will overwrite the use of the userNameProperty
.
The user identifier passed into the RaygunIdentifierMessage constructor could be the users name, email address, database id or whatever works best for you to identify unique users.
var userInfo = new RaygunIdentifierMessage("12345")
{
FirstName = "John",
FullName = "John Doe",
Email = "johndoe@email.address"
};
Log.ForContext("CustomUserInfoProperty", userInfo, true).Error(new Exception("random error"), "other information");
onBeforeSend
type: Action<OnBeforeSendParameters>
default: null
This action allows you to manipulate the crash report payloads that get sent to Raygun. By default it is null
, so you don't need to set it in the constructor. If the action is null
, nothing happens; if an Action<OnBeforeSendParameters>
is passed, it gets called just before the crash report payload gets serialized and sent to Raygun. The arguments to the action are of type Struct OnBeforeSendArguments
; they are passed to the action when it is called and contain references to the following objects passed by the Raygun client object:
// Abstracted away version of the struct to just show the properties
struct OnBeforeSendArguments
{
System.Exception Exception;
Mindscape.Raygun4Net.Messages.RaygunMessage RaygunMessage;
}
The provided action can read and/or modify their properties accordingly to produce the desired effect. For example, one can change the MachineName
property in the Details
of the RaygunMessage
as follows:
Log.Logger = new LoggerConfiguration()
.MinimumLevel.Verbose()
.WriteTo.Raygun(
applicationKey: "paste_your_api_key_here",
onBeforeSend: arguments => {
arguments.RaygunMessage.Details.MachineName = "MyMachine";
})
.CreateLogger();
Enrich with HTTP request and response data
Properties included from other Serilog Enrichers should automatically be included into the Raygun errors.
To use the old Raygun Enricher you can follow the Enricher Readme to add the enricher to your project.
Raygun4Net features configured via RaygunSettings
This sink wraps the Raygun4Net provider to build a crash report from an Exception and send it to Raygun. This makes the following Raygun4Net features available to you. To use these features, you need to add RaygunSettings to your configuration as explained below which is separate to the Serilog configuration.
.NET Framework
Add the following section within the configSections element of your app.config or web.config file.
<section name="RaygunSettings" type="Mindscape.Raygun4Net.RaygunSettings, Mindscape.Raygun4Net"/>
Then add a RaygunSettings element containing the desired settings somewhere within the configuration element of the app.config or web.config file.
<RaygunSettings setting="value"/>
ThrowOnError
type: bool
default: false
This is false by default. Which means that any exception that occur within Raygun4Net itself will be silently caught. Setting this to true will allow any exceptions occurring in Raygun4Net to be thrown, which can help debug issues with Raygun4Net if crash reports aren't showing up in Raygun.
IgnoreSensitiveFieldNames
type: string[]
default: null
Crash reports sent to Raygun from this Serilog sink will include HTTP context details if present. (Currently only supported in .NET Framework applications). IgnoreSensitiveFieldNames
lets you specify a list of HTTP query parameters, form fields, headers, cookies and server variables that you do not want to be sent to Raygun. Additionally, entries in this setting will be attempted to be stripped out of the raw request payload (more options for controlling this are explained in the IsRawDataIgnored
section below).
Setting IgnoreSensitiveFieldNames
to a list that only contains "*" will cause none of these things to be sent to Raygun. Placing *
before, after or at both ends of an entry will perform an ends-with, starts-with or contains operation respectively.
Individual options are also available which function in the same way as IgnoreSensitiveFieldNames
: IgnoreQueryParameterNames
, IgnoreFormFieldNames
, IgnoreHeaderNames
, IgnoreCookieNames
and IgnoreServerVariableNames
.
The IgnoreFormFieldNames
entries will also strip out specified values from the raw request payload if it is multipart/form-data.
IsRawDataIgnored
type: bool
default: false
By default, Raygun crash reports will capture the raw request payload of the current HTTP context if present. (Currently only supported in .NET Framework applications). If you would not like to include raw request payloads on crash reports sent to Raygun, then you can set IsRawDataIgnored
to true.
If you do want to include the raw request payload, but want to filter out sensitive fields, then you can use the IgnoreSensitiveFieldNames
options described above. You'll also need to specify how the fields should be stripped from the raw request payload. Set UseXmlRawDataFilter
to true for XML payloads or/and set UseKeyValuePairRawDataFilter
to true for payloads of the format "key1=value1&key2=value2".
Setting IsRawDataIgnoredWhenFilteringFailed
to true will cause the entire raw request payload to be ignored in cases where specified sensitive values fail to be stripped out.
CrashReportingOfflineStorageEnabled
type: bool
default: true
Only available in .NET Framework applications. This is true by default which will cause crash reports to be saved to isolated storage (if possible) in cases where they fail to be sent to Raygun. This option lets you disable this functionality by setting it to false. When enabled, a maximum of 64 crash reports can be saved. This limit can be set lower than 64 via the MaxCrashReportsStoredOffline
option.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 is compatible. net5.0-windows was computed. net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 is compatible. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETFramework 4.6.2
- Microsoft.NETFramework.ReferenceAssemblies.net462 (>= 1.0.3)
- Mindscape.Raygun4Net (>= 8.0.0)
- Serilog (>= 2.12.0)
-
.NETStandard 2.0
- Mindscape.Raygun4Net.NetCore (>= 8.0.0)
- Serilog (>= 2.12.0)
-
net5.0
- Mindscape.Raygun4Net.NetCore (>= 8.0.0)
- Serilog (>= 2.12.0)
-
net6.0
- Mindscape.Raygun4Net.NetCore (>= 8.0.0)
- Serilog (>= 2.12.0)
-
net7.0
- Mindscape.Raygun4Net.NetCore (>= 8.0.0)
- Serilog (>= 2.12.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Serilog.Sinks.Raygun:
Package | Downloads |
---|---|
UniLogger
Logger for MVC and Core applications |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
8.0.0 | 9,186 | 8/25/2024 |
7.6.0-pre-1 | 231 | 8/13/2024 |
7.5.0 | 34,787 | 2/12/2024 |
7.5.0-pre-1 | 111 | 2/1/2024 |
7.4.0 | 19,243 | 1/22/2024 |
7.4.0-pre-1 | 113 | 1/17/2024 |
7.3.0 | 9,918 | 11/14/2023 |
7.3.0-pre-2 | 148 | 11/10/2023 |
7.3.0-pre-1 | 149 | 11/10/2023 |
7.2.0-pre-1 | 152 | 10/25/2023 |
7.1.0 | 7,798 | 10/9/2023 |
7.0.0 | 640 | 9/21/2023 |
7.0.0-pre-2 | 163 | 9/20/2023 |
7.0.0-pre-1 | 131 | 9/15/2023 |
5.3.3 | 34,595 | 6/15/2023 |
5.3.1 | 20,073 | 5/18/2023 |
5.3.0 | 1,658 | 4/28/2023 |
5.2.0 | 2,138 | 3/29/2023 |
5.1.1 | 138,674 | 3/3/2022 |
5.1.1-dev-00108 | 205 | 3/3/2022 |
5.1.1-dev-00107 | 192 | 3/3/2022 |
5.1.0 | 1,969 | 2/4/2022 |
5.1.0-dev-00102 | 188 | 2/4/2022 |
5.0.3-dev-00101 | 193 | 2/4/2022 |
5.0.3-dev-00097 | 194 | 1/16/2022 |
5.0.3-dev-00089 | 361 | 6/22/2021 |
5.0.2 | 406,969 | 6/21/2021 |
5.0.2-dev-00086 | 271 | 6/21/2021 |
5.0.2-dev-00083 | 316 | 6/21/2021 |
5.0.1 | 443,358 | 10/26/2020 |
5.0.1-dev-00074 | 422 | 10/26/2020 |
5.0.0 | 651 | 10/26/2020 |
4.0.1-dev-00070 | 390 | 10/26/2020 |
4.0.1-dev-00056 | 421 | 10/1/2020 |
4.0.1-dev-00048 | 407 | 9/1/2020 |
4.0.1-dev-00045 | 416 | 8/16/2020 |
4.0.1-dev-00040 | 367 | 8/10/2020 |
4.0.1-dev-00039 | 385 | 8/10/2020 |
4.0.1-dev-00038 | 373 | 8/10/2020 |
4.0.0 | 293,903 | 2/18/2020 |
4.0.0-dev-00029 | 5,337 | 7/16/2019 |
3.0.1-dev-00026 | 28,729 | 9/5/2018 |
3.0.1-dev-00024 | 1,211 | 7/13/2018 |
3.0.1-dev-00022 | 836 | 5/9/2018 |
3.0.1-dev-00021 | 3,964 | 4/30/2018 |
3.0.0 | 723,961 | 12/6/2017 |
2.0.15 | 37,665 | 5/22/2017 |
2.0.13 | 15,031 | 1/12/2017 |
1.5.10 | 10,811 | 9/30/2016 |
1.5.8 | 17,672 | 12/16/2015 |
1.5.6 | 4,134 | 5/14/2015 |
1.5.3 | 1,721 | 4/1/2015 |
1.5.2 | 1,212 | 3/30/2015 |
1.5.1 | 1,178 | 3/27/2015 |
1.4.196 | 1,685 | 2/22/2015 |
1.4.182 | 1,451 | 2/15/2015 |
1.4.168 | 1,310 | 2/8/2015 |
1.4.155 | 1,161 | 2/1/2015 |
1.4.139 | 1,217 | 1/23/2015 |
1.4.118 | 1,222 | 1/13/2015 |
1.4.113 | 1,146 | 1/6/2015 |
1.4.102 | 1,487 | 12/21/2014 |
1.4.99 | 2,012 | 12/18/2014 |
1.4.97 | 1,485 | 12/18/2014 |
1.4.76 | 1,415 | 12/8/2014 |
1.4.39 | 1,748 | 11/26/2014 |
1.4.34 | 1,344 | 11/24/2014 |
1.4.28 | 1,307 | 11/24/2014 |
1.4.27 | 1,334 | 11/23/2014 |
1.4.23 | 1,395 | 11/21/2014 |
1.4.21 | 1,326 | 11/21/2014 |
1.4.18 | 1,550 | 11/18/2014 |
1.4.15 | 2,241 | 11/4/2014 |
1.4.14 | 1,242 | 10/23/2014 |
1.4.13 | 1,164 | 10/23/2014 |
1.4.12 | 1,238 | 10/12/2014 |
1.4.11 | 1,213 | 10/8/2014 |
1.4.10 | 1,181 | 9/26/2014 |
1.4.9 | 1,196 | 9/17/2014 |
1.4.8 | 1,163 | 9/11/2014 |
1.4.7 | 1,188 | 9/1/2014 |
1.4.6 | 1,144 | 8/31/2014 |
1.4.5 | 1,178 | 8/27/2014 |
1.4.4 | 1,219 | 8/27/2014 |
1.4.3 | 1,264 | 8/25/2014 |
1.4.2 | 1,222 | 8/23/2014 |
1.4.1 | 1,200 | 8/23/2014 |
1.3.43 | 1,280 | 8/4/2014 |
1.3.42 | 1,172 | 7/30/2014 |
1.3.41 | 1,166 | 7/28/2014 |
1.3.40 | 1,155 | 7/26/2014 |
1.3.39 | 1,201 | 7/25/2014 |
1.3.36 | 1,184 | 7/20/2014 |
1.3.35 | 1,180 | 7/17/2014 |
1.3.34 | 1,198 | 7/6/2014 |
1.3.33 | 1,205 | 6/30/2014 |
1.3.30 | 1,227 | 6/19/2014 |
1.3.29 | 1,260 | 6/19/2014 |
1.3.28 | 1,201 | 6/19/2014 |
1.3.27 | 1,164 | 6/18/2014 |
1.3.25 | 1,233 | 6/9/2014 |
1.3.24 | 1,224 | 5/21/2014 |
1.3.23 | 1,185 | 5/20/2014 |
1.3.20 | 1,227 | 5/18/2014 |
1.3.19 | 1,267 | 5/17/2014 |
1.3.18 | 1,217 | 5/17/2014 |
1.3.17 | 1,342 | 5/17/2014 |
1.3.16 | 1,177 | 5/17/2014 |
1.3.15 | 1,207 | 5/16/2014 |
1.3.14 | 1,214 | 5/16/2014 |
1.3.13 | 1,247 | 5/16/2014 |
1.3.12 | 1,223 | 5/14/2014 |