Skip to content

Commit

Permalink
Merge pull request #34 from serilog/dev
Browse files Browse the repository at this point in the history
5.0.1 Release
  • Loading branch information
nblumhardt authored Oct 26, 2020
2 parents 4cb1b93 + 7c7416c commit ef44627
Show file tree
Hide file tree
Showing 5 changed files with 359 additions and 94 deletions.
144 changes: 128 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,28 @@ Log.Logger = new LoggerConfiguration()
new[] { "globalTag1", "globalTag2" },
new[] { "ignoreField1", "ignoreField2" },
"CustomGroupKeyProperty",
"CustomTagsProperty")
"CustomTagsProperty",
"CustomUserInfoProperty")
.CreateLogger();
```
### Required
#### applicationKey
`string`

### Optional
#### wrapperExceptions
`type: IEnumerable<Exception>`
### 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`

#### userNameProperty
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`
Expand All @@ -40,50 +48,154 @@ Log.Logger = new LoggerConfiguration()
Log.ForContext("CustomUserNameProperty", "John Doe").Error(new Exception("random error"), "other information");
```

#### applicationVersionProperty
### 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.

```csharp
Log.ForContext("CustomAppVersionProperty", "1.2.11").Error(new Exception("random error"), "other information");
```

#### restrictedToMinimumLevel
### restrictedToMinimumLevel
`type: LogEventLevel`

`default: LogEventLevel.Error`

#### formatProvider
### formatProvider
`type: IFormatProvider`

`default: null`

#### tags
### tags
`type: IEnumerable<string>`

`default: null`

#### ignoredFormFieldNames
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`

#### groupKeyProperty
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](#raygun4net-features-configured-via-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.

```csharp
Log.ForContext("CustomGroupKeyProperty", "TransactionId-12345").Error(new Exception("random error"), "other information");
```

#### tagsProperty
### 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](#tags). 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.

```csharp
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.

```csharp
var userInfo = new RaygunIdentifierMessage("12345")
{
FirstName = "John",
FullName = "John Doe",
Email = "[email protected]"
};

Log.ForContext("CustomUserInfoProperty", userInfo, true).Error(new Exception("random error"), "other information");
```

## Raygun4Net features configured via RaygunSettings

This sink wraps the [Raygun4Net](https://github.com/MindscapeHQ/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 Core**

Add a RaygunSettings block to your appsettings.config file where you can populate the settings that you want to use.

```
"RaygunSettings": {
"Setting": "Value"
}
```

**.NET Framework**

Add the following section within the configSections element of your app.config or web.config file.

```xml
<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.

```xml
<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.
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ artifacts:
deploy:
- provider: NuGet
api_key:
secure: eY0pNgTWxzEUVfkitD3R/g5Qfg2GVLYdiJiyvnwfiOLBd2FMRRrJKD89j8XMeK9A
secure: K3/810hkTO6rd2AEHVkUQAadjGmDREus9k96QHu6hxrA1/wRTuAJemHMKtVVgIvf
skip_symbols: true
on:
branch: /^(master|dev)$/
Expand Down
12 changes: 5 additions & 7 deletions src/Serilog.Sinks.Raygun/LoggerConfigurationRaygunExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ namespace Serilog
public static class LoggerConfigurationRaygunExtensions
{
/// <summary>
/// Adds a sink that writes log events (defaults to error and up) to the Raygun.io webservice. Properties are being send as data and the level is used as a tag.
/// Adds a sink that writes log events (defaults to error and up) to the Raygun service. Properties and the log message are being attached as UserCustomData and the level is included as a Tag.
/// Your message is part of the custom data.
/// </summary>
/// <param name="loggerConfiguration">The logger configuration.</param>
/// <param name="applicationKey">The application key as found on the Raygun.io website.</param>
/// <param name="applicationKey">The application key as found on an application in your Raygun account.</param>
/// <param name="wrapperExceptions">If you have common outer exceptions that wrap a valuable inner exception which you'd prefer to group by, you can specify these by providing a list.</param>
/// <param name="userNameProperty">Specifies the property name to read the username from. By default it is UserName. Set to null if you do not want to use this feature.</param>
/// <param name="applicationVersionProperty">Specifies the property to use to retrieve the application version from. You can use an enricher to add the application version to all the log events. When you specify null, Raygun will use the assembly version.</param>
Expand All @@ -53,15 +53,13 @@ public static LoggerConfiguration Raygun(
IEnumerable<string> tags = null,
IEnumerable<string> ignoredFormFieldNames = null,
string groupKeyProperty = "GroupKey",
string tagsProperty = "Tags")
string tagsProperty = "Tags",
string userInfoProperty = null)
{
if (loggerConfiguration == null) throw new ArgumentNullException("loggerConfiguration");

if (string.IsNullOrWhiteSpace(applicationKey))
throw new ArgumentNullException("applicationKey");

return loggerConfiguration.Sink(
new RaygunSink(formatProvider, applicationKey, wrapperExceptions, userNameProperty, applicationVersionProperty, tags, ignoredFormFieldNames, groupKeyProperty, tagsProperty),
new RaygunSink(formatProvider, applicationKey, wrapperExceptions, userNameProperty, applicationVersionProperty, tags, ignoredFormFieldNames, groupKeyProperty, tagsProperty, userInfoProperty),
restrictedToMinimumLevel);
}
}
Expand Down
17 changes: 7 additions & 10 deletions src/Serilog.Sinks.Raygun/Serilog.Sinks.Raygun.csproj
Original file line number Diff line number Diff line change
@@ -1,35 +1,32 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0;net46;net461</TargetFrameworks>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Authors>Michiel van Oudheusden</Authors>
<Company>Serilog</Company>
<Product>Serilog.Sinks.Raygun</Product>
<Description>Send log events to custom topics in Azure Event Grid</Description>
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
<PackageProjectUrl>http://serilog.net</PackageProjectUrl>
<PackageIconUrl>http://serilog.net/images/serilog-sink-nuget.png</PackageIconUrl>
<RepositoryType>git</RepositoryType>
<RepositoryUrl>https://github.com/serilog/serilog-sinks-raygun</RepositoryUrl>
<PackageTags>serilog sink raygun</PackageTags>
<Copyright>Copyright © Serilog Contributors 2017-2019</Copyright>
<Description>Serilog event sink that writes to the Raygun.io service.</Description>
<VersionPrefix>4.0.0</VersionPrefix>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<FileVersion>4.0.0.0</FileVersion>
<Copyright>Copyright © Serilog Contributors 2017-2020</Copyright>
<Description>Serilog event sink that writes to the Raygun service.</Description>
<VersionPrefix>5.0.1</VersionPrefix>
</PropertyGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net46'">
<PackageReference Include="Mindscape.Raygun4Net" Version="5.5.2" />
<PackageReference Include="Mindscape.Raygun4Net" Version="5.12.0" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net461'">
<PackageReference Include="Mindscape.Raygun4Net" Version="5.5.2" />
<PackageReference Include="Mindscape.Raygun4Net" Version="5.12.0" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<PackageReference Include="mindscape.Raygun4Net.AspNetCore" Version="6.0.0" />
<PackageReference Include="mindscape.Raygun4Net.AspNetCore" Version="6.4.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Loading

0 comments on commit ef44627

Please sign in to comment.