Skip to content

Commit 0dcf2d1

Browse files
authored
Merge pull request #384 from serilog/dev
Release 5.7.0
2 parents 55645b5 + bb86626 commit 0dcf2d1

File tree

19 files changed

+109
-55
lines changed

19 files changed

+109
-55
lines changed

.github/ISSUE_TEMPLATE.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ If you are opening a feature request, you can ignore this template. Bug reports
1414

1515
>> Target framework and operating system:
1616
17-
[ ] .NET Core 2.0
17+
[ ] .NET Core 6
18+
[ ] .NET Core 3.1
19+
[ ] .NET Framework 4.8
1820
[ ] .NET Framework 4.7
1921
[ ] .NET Framework 4.6.x
2022
[ ] .NET Framework 4.5.x

CHANGES.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# 5.7.0
2+
* Fixed a wrong information in README.md regarding SQL Server compatibility (thanks to @domagojmedo).
3+
* Fixed bug #382 System.FormatExceotion due to invalid format strings when using SelfLog (thanks to @sommmen)
4+
* New sink option to configure tenant when using Azure managed identities (thanks to @mattosaurus).
5+
* Updated .NET target frameworks (obsolete .NET Core 2.0 and 2.1, added .NET Core 3.1 LTS).
6+
17
# 5.6.1
28
* Added support for reserved columns (thanks to @susanneschuster).
39
* Fixes in README.
@@ -24,7 +30,7 @@
2430
# 5.4.0
2531
* Added support for Azure Managed Identities for Resources authentication (thanks to @darrenschwarz for the contribution).
2632
* New interface using `SinkOptions` parameter. Marked old interfaces obsolete.
27-
* Implemented Enhancement #182: configurable property names for custom columns (thanks to @rocknet for the contribution).
33+
* Implemented Enhancement #182: configurable property names for custom columns (thanks to @rocknet for the contribution).
2834
* Lots of refactoring and new unit tests.
2935

3036
# 5.3.0

README.md

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,13 @@ Because of the way external configuration has been implemented in various .NET f
8888
| Your Framework | TFM | Project Types | External Configuration |
8989
| --- | --- | --- | --- |
9090
| .NET Framework 4.5.2 | `net452` | app or library | _System.Configuration_ |
91-
| .NET Framework 4.6.1+ | `net461` | app or library | _System.Configuration_ |
92-
| .NET Framework 4.6.1+ | `net461` | app or library | _Microsoft.Extensions.Configuration_ |
91+
| .NET Framework 4.6.2+ | `net462` | app or library | _System.Configuration_ |
92+
| .NET Framework 4.6.2+ | `net462` | app or library | _Microsoft.Extensions.Configuration_ |
9393
| .NET Standard 2.0 | `netstandard2.0` | library only | _Microsoft.Extensions.Configuration_ |
94-
| .NET Core 2.0+ | `netcoreapp2.0` | app or library | _System.Configuration_ |
95-
| .NET Core 2.0+ | `netcoreapp2.0` | app or library | _Microsoft.Extensions.Configuration_ |
94+
| .NET Core 3.1+ | `netcoreapp3.1` | app or library | _System.Configuration_ |
95+
| .NET Core 3.1+ | `netcoreapp3.1` | app or library | _Microsoft.Extensions.Configuration_ |
9696

97-
Support for .NET Framework 4.5.2 is tied to the Windows 8.1 lifecycle with support scheduled to end in January 2023.
97+
Support for .NET Framework 4.5.2 is tied to the Windows 8.1 lifecycle with support scheduled to end in April 2022 (https://devblogs.microsoft.com/dotnet/net-framework-4-5-2-4-6-4-6-1-will-reach-end-of-support-on-april-26-2022/).
9898

9999
Although it's possible to use both XML and _M.E.C_ configuration with certain frameworks, this is not supported, unintended consequences are possible, and a warning will be emitted to `SelfLog`. If you actually require multiple configuration sources, the _M.E.C_ builder-pattern is designed to support this, and your syntax will be consistent across configuration sources.
100100

@@ -247,6 +247,7 @@ Basic settings of the sink are configured using the properties in a `MSSqlServer
247247
* `EagerlyEmitFirstEvent`
248248
* `UseAzureManagedIdentity`
249249
* `AzureServiceTokenProviderResource`
250+
* `AzureTenantId`
250251

251252
### TableName
252253

@@ -285,7 +286,24 @@ See [Azure AD-managed identities for Azure resources documentation](https://docs
285286

286287
### AzureServiceTokenProviderResource
287288

288-
Specifies the token provider resource to be used for aquiring an authentication token when using Azure Managed Identities for authenticating with an Azure SQL server. This setting is only used if `UseAzureManagedIdentity` is set to `true`.
289+
Specifies the token provider resource to be used for aquiring an authentication token when using Azure Managed Identities for authenticating with an Azure SQL server. This setting is only used if `UseAzureManagedIdentity` is set to `true`. For Azure SQL databases this value will always be `https://database.windows.net/`.
290+
291+
### AzureTenantId
292+
293+
Specifies the tenant ID of the the tenant the Azure SQL database exists in. This only needs to be set if the user authenticating against the database is in a different tenant to the database. This will most likely be the case when you are debugging locally and authenticating as yourself rather than the app to be deployed to.
294+
295+
```
296+
.WriteTo.MSSqlServer(
297+
Environment.GetEnvironmentVariable("LogConnection"),
298+
sinkOptions: new MSSqlServerSinkOptions()
299+
{
300+
TableName = "_Log",
301+
UseAzureManagedIdentity = true,
302+
AzureServiceTokenProviderResource = "https://database.windows.net/",
303+
AzureTenantId = Environment.GetEnvironmentVariable("AZURE_TENANT_ID")
304+
}
305+
```
306+
289307

290308
## ColumnOptions Object
291309

@@ -736,7 +754,7 @@ Extracting and querying the property column directly can be helpful when looking
736754

737755
### LogEvent JSON
738756

739-
This capability requires SQL 2012 or newer. Given the following JSON properties:
757+
This capability requires SQL 2016 or newer. Given the following JSON properties:
740758

741759
```json
742760
{

sample/AppConfigDemo/AppConfigDemo.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<OutputType>Exe</OutputType>
99
<RootNamespace>AppConfigDemo</RootNamespace>
1010
<AssemblyName>AppConfigDemo</AssemblyName>
11-
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
11+
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
1212
<FileAlignment>512</FileAlignment>
1313
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
1414
<Deterministic>true</Deterministic>
@@ -126,4 +126,4 @@
126126
</PropertyGroup>
127127
<Error Condition="!Exists('..\..\packages\Microsoft.Data.SqlClient.SNI.1.1.0\build\net46\Microsoft.Data.SqlClient.SNI.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Microsoft.Data.SqlClient.SNI.1.1.0\build\net46\Microsoft.Data.SqlClient.SNI.targets'))" />
128128
</Target>
129-
</Project>
129+
</Project>

src/Serilog.Sinks.MSSqlServer/Configuration/Implementations/Microsoft.Extensions.Configuration/MicrosoftExtensionsSinkOptionsProvider.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ private static void ReadAzureManagedIdentitiesOptions(IConfigurationSection conf
3838
{
3939
SetProperty.IfNotNull<bool>(config["useAzureManagedIdentity"], val => sinkOptions.UseAzureManagedIdentity = val);
4040
SetProperty.IfNotNull<string>(config["azureServiceTokenProviderResource"], val => sinkOptions.AzureServiceTokenProviderResource = val);
41+
SetProperty.IfNotNull<string>(config["azureTenantId"], val => sinkOptions.AzureTenantId = val);
4142
}
4243
}
4344
}

src/Serilog.Sinks.MSSqlServer/Configuration/Implementations/System.Configuration/MSSqlServerConfigurationSection.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,13 @@ public ValueConfigElement AzureServiceTokenProviderResource
191191
{
192192
get => (ValueConfigElement)base[nameof(AzureServiceTokenProviderResource)];
193193
}
194+
195+
196+
[ConfigurationProperty(nameof(AzureTenantId))]
197+
public ValueConfigElement AzureTenantId
198+
{
199+
get => (ValueConfigElement)base[nameof(AzureTenantId)];
200+
}
194201
}
195202
}
196203

src/Serilog.Sinks.MSSqlServer/Serilog.Sinks.MSSqlServer.csproj

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
<PropertyGroup>
44
<Description>A Serilog sink that writes events to Microsoft SQL Server</Description>
5-
<VersionPrefix>5.6.1</VersionPrefix>
5+
<VersionPrefix>5.7.0</VersionPrefix>
66
<Authors>Michiel van Oudheusden;Christian Kadluba;Serilog Contributors</Authors>
7-
<TargetFrameworks>netstandard2.0;net452;net461;net472;netcoreapp2.0;netcoreapp2.1</TargetFrameworks>
7+
<TargetFrameworks>netstandard2.0;net452;net462;net472;netcoreapp3.1</TargetFrameworks>
88
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
99
<GenerateDocumentationFile>true</GenerateDocumentationFile>
1010
<AssemblyName>Serilog.Sinks.MSSqlServer</AssemblyName>
@@ -67,8 +67,7 @@
6767
<Compile Include="Configuration\Implementations\Microsoft.Extensions.Configuration\**\*.cs" />
6868
<Compile Include="Sinks\MSSqlServer\Platform\AzureManagedServiceAuthenticatorStub.cs" />
6969
</ItemGroup>
70-
71-
<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp2.0' Or '$(TargetFramework)' == 'net461' ">
70+
<ItemGroup Condition=" '$(TargetFramework)' == 'net462' ">
7271
<PackageReference Include="System.Configuration.ConfigurationManager" Version="4.5.0" />
7372
<PackageReference Include="Microsoft.Data.SqlClient" Version="1.1.3" />
7473
<PackageReference Include="Microsoft.Extensions.Configuration" Version="2.0.0" />
@@ -79,7 +78,7 @@
7978
<Compile Include="Sinks\MSSqlServer\Platform\AzureManagedServiceAuthenticatorStub.cs" />
8079
</ItemGroup>
8180

82-
<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp2.1' Or '$(TargetFramework)' == 'net472' ">
81+
<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp3.1' Or '$(TargetFramework)' == 'net472' ">
8382
<PackageReference Include="System.Configuration.ConfigurationManager" Version="4.5.0" />
8483
<PackageReference Include="Microsoft.Data.SqlClient" Version="1.1.3" />
8584
<PackageReference Include="Microsoft.Azure.Services.AppAuthentication" Version="1.4.0" />

src/Serilog.Sinks.MSSqlServer/Sinks/MSSqlServer/ColumnOptions/FinalizeConfigurationForSinkConstructor.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ internal void FinalizeConfigurationForSinkConstructor()
6868
// PK must always be NON-NULL
6969
if (PrimaryKey != null && PrimaryKey.AllowNull == true)
7070
{
71-
SelfLog.WriteLine($"Warning: Primary key must be NON-NULL, changing AllowNull property for {PrimaryKey.ColumnName} column.");
71+
SelfLog.WriteLine("Warning: Primary key must be NON-NULL, changing AllowNull property for {0} column.", PrimaryKey.ColumnName);
7272
PrimaryKey.AllowNull = false;
7373
}
7474

@@ -81,7 +81,7 @@ private static void ColumnstoreCompatibilityCheck(SqlColumn column)
8181
throw new ArgumentException($"Columnstore indexes do not support data type \"{column.DataType}\" declared for column \"{column.ColumnName}\".");
8282

8383
if (column.DataLength == -1 && SqlDataTypes.DataLengthRequired.Contains(column.DataType))
84-
SelfLog.WriteLine($"Warning: SQL2017 or newer required to use columnstore index with MAX length column \"{column.ColumnName}\".");
84+
SelfLog.WriteLine("Warning: SQL2017 or newer required to use columnstore index with MAX length column \"{0}\".", column.ColumnName);
8585
}
8686
}
8787
}

src/Serilog.Sinks.MSSqlServer/Sinks/MSSqlServer/Dependencies/SinkDependenciesFactory.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ internal static SinkDependencies Create(
2222
sinkOptions?.UseAzureManagedIdentity ?? default,
2323
new AzureManagedServiceAuthenticator(
2424
sinkOptions?.UseAzureManagedIdentity ?? default,
25-
sinkOptions.AzureServiceTokenProviderResource));
25+
sinkOptions.AzureServiceTokenProviderResource,
26+
sinkOptions.AzureTenantId));
2627
var logEventDataGenerator =
2728
new LogEventDataGenerator(columnOptions,
2829
new StandardColumnDataGenerator(columnOptions, formatProvider,

src/Serilog.Sinks.MSSqlServer/Sinks/MSSqlServer/MSSqlServerSinkOptions.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,5 +71,10 @@ internal MSSqlServerSinkOptions(
7171
/// Azure service token provider to be used for Azure Managed Identities
7272
/// </summary>
7373
public string AzureServiceTokenProviderResource { get; set; }
74+
75+
/// <summary>
76+
/// ID of the tenant where the Azure resource exists
77+
/// </summary>
78+
public string AzureTenantId { get; set; }
7479
}
7580
}

0 commit comments

Comments
 (0)