Skip to content

Commit 5bfc443

Browse files
authored
Merge pull request #106 from serilog/dev
5.1.0 Release
2 parents 72609ff + 9243709 commit 5bfc443

18 files changed

+200
-1870
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,3 +181,5 @@ UpgradeLog*.htm
181181

182182
# Microsoft Fakes
183183
FakesAssemblies/
184+
/.vs/serilog-sinks-mssqlserver/v15/sqlite3
185+
/.vs/serilog-sinks-mssqlserver/v15/Server/sqlite3

Build.ps1

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,13 @@ echo "build: Version suffix is $suffix"
1818
foreach ($src in ls src/*) {
1919
Push-Location $src
2020

21-
echo "build: Packaging project in $src"
21+
echo "build: Packaging project in $src"
2222

23-
& dotnet pack -c Release -o ..\..\artifacts --version-suffix=$suffix
23+
if ($suffix) {
24+
& dotnet pack -c Release -o ..\..\artifacts --version-suffix=$suffix
25+
} else {
26+
& dotnet pack -c Release -o ..\..\artifacts
27+
}
2428
if($LASTEXITCODE -ne 0) { exit 1 }
2529

2630
Pop-Location
@@ -29,7 +33,7 @@ foreach ($src in ls src/*) {
2933
foreach ($test in ls test/*.PerformanceTests) {
3034
Push-Location $test
3135

32-
echo "build: Building performance test project in $test"
36+
echo "build: Building performance test project in $test"
3337

3438
& dotnet build -c Release
3539
if($LASTEXITCODE -ne 0) { exit 2 }
@@ -40,7 +44,7 @@ foreach ($test in ls test/*.PerformanceTests) {
4044
foreach ($test in ls test/*.Tests) {
4145
Push-Location $test
4246

43-
echo "build: Testing project in $test"
47+
echo "build: Testing project in $test"
4448

4549
& dotnet test -c Release
4650
if($LASTEXITCODE -ne 0) { exit 3 }

README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
# Serilog.Sinks.MSSqlServer
2-
3-
[![Build status](https://ci.appveyor.com/api/projects/status/3btbux1hbgyugind/branch/master?svg=true)](https://ci.appveyor.com/project/serilog/serilog-sinks-mssqlserver/branch/master)
1+
# Serilog.Sinks.MSSqlServer [![Build status](https://ci.appveyor.com/api/projects/status/3btbux1hbgyugind/branch/master?svg=true)](https://ci.appveyor.com/project/serilog/serilog-sinks-mssqlserver/branch/master) [![NuGet](https://img.shields.io/nuget/v/Serilog.Sinks.MSSqlServer.svg)](https://nuget.org/packages/Serilog.Sinks.MSSqlServer)
42

53
A Serilog sink that writes events to Microsoft SQL Server. While a NoSql store allows for more flexibility to store the different kinds of properties, it sometimes is easier to use an already existing MS SQL server. This sink will write the logevent data to a table and can optionally also store the properties inside an Xml column so they can be queried.
64

75
**Package** - [Serilog.Sinks.MSSqlServer](http://nuget.org/packages/serilog.sinks.mssqlserver)
8-
| **Platforms** - .NET 4.5
6+
| **Platforms** - .NET 4.5 and .NET Standard 2.0
97

108
## Configuration
119

appveyor.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
version: '{build}'
22
skip_tags: true
3-
image: Visual Studio 2015
3+
image: Visual Studio 2017
44
configuration: Release
55
install:
66
- ps: mkdir -Force ".\build\" | Out-Null
7-
- ps: Invoke-WebRequest "https://raw.githubusercontent.com/dotnet/cli/rel/1.0.0-preview2/scripts/obtain/dotnet-install.ps1" -OutFile ".\build\installcli.ps1"
8-
- ps: $env:DOTNET_INSTALL_DIR = "$pwd\.dotnetcli"
9-
- ps: '& .\build\installcli.ps1 -InstallDir "$env:DOTNET_INSTALL_DIR" -NoPath -Version 1.0.0-preview2-003121'
10-
- ps: $env:Path = "$env:DOTNET_INSTALL_DIR;$env:Path"
117
build_script:
128
- ps: ./Build.ps1
139
test: off

global.json

Lines changed: 0 additions & 6 deletions
This file was deleted.

serilog-sinks-mssqlserver.sln

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,24 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio 14
4-
VisualStudioVersion = 14.0.25420.1
3+
# Visual Studio 15
4+
VisualStudioVersion = 15.0.26730.16
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{04226074-C72F-42BC-AB02-4D70A7BAE7E1}"
77
EndProject
8-
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Serilog.Sinks.MSSqlServer", "src\Serilog.Sinks.MSSqlServer\Serilog.Sinks.MSSqlServer.xproj", "{803CD13A-D54B-4CEC-A55F-E22AE3D93B3C}"
9-
EndProject
108
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{F02D6513-6F45-452E-85A0-41A872A2C1F8}"
119
EndProject
12-
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Serilog.Sinks.MSSqlServer.Tests", "test\Serilog.Sinks.MSSqlServer.Tests\Serilog.Sinks.MSSqlServer.Tests.xproj", "{3C2D8E01-5580-426A-BDD9-EC59CD98E618}"
13-
EndProject
1410
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{70667ADA-A2FD-4821-A6A1-8D18D0D71507}"
1511
ProjectSection(SolutionItems) = preProject
1612
appveyor.yml = appveyor.yml
1713
Build.ps1 = Build.ps1
1814
CHANGES.md = CHANGES.md
19-
global.json = global.json
2015
README.md = README.md
2116
EndProjectSection
2217
EndProject
18+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Serilog.Sinks.MSSqlServer", "src\Serilog.Sinks.MSSqlServer\Serilog.Sinks.MSSqlServer.csproj", "{803CD13A-D54B-4CEC-A55F-E22AE3D93B3C}"
19+
EndProject
20+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Serilog.Sinks.MSSqlServer.Tests", "test\Serilog.Sinks.MSSqlServer.Tests\Serilog.Sinks.MSSqlServer.Tests.csproj", "{3C2D8E01-5580-426A-BDD9-EC59CD98E618}"
21+
EndProject
2322
Global
2423
GlobalSection(SolutionConfigurationPlatforms) = preSolution
2524
Debug|Any CPU = Debug|Any CPU
@@ -42,4 +41,7 @@ Global
4241
{803CD13A-D54B-4CEC-A55F-E22AE3D93B3C} = {04226074-C72F-42BC-AB02-4D70A7BAE7E1}
4342
{3C2D8E01-5580-426A-BDD9-EC59CD98E618} = {F02D6513-6F45-452E-85A0-41A872A2C1F8}
4443
EndGlobalSection
44+
GlobalSection(ExtensibilityGlobals) = postSolution
45+
SolutionGuid = {AAA6BF8D-7B53-4A5F-A79A-D1B306383B45}
46+
EndGlobalSection
4547
EndGlobal
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<Description>A Serilog sink that writes events to Microsoft SQL Server</Description>
5+
<VersionPrefix>5.1.0</VersionPrefix>
6+
<Authors>Michiel van Oudheusden;Serilog Contributors</Authors>
7+
<TargetFrameworks>netstandard2.0;net45;net452</TargetFrameworks>
8+
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
9+
<GenerateDocumentationFile>true</GenerateDocumentationFile>
10+
<AssemblyName>Serilog.Sinks.MSSqlServer</AssemblyName>
11+
<AssemblyOriginatorKeyFile>../../assets/Serilog.snk</AssemblyOriginatorKeyFile>
12+
<SignAssembly>true</SignAssembly>
13+
<PublicSign Condition=" '$(OS)' != 'Windows_NT' ">true</PublicSign>
14+
<PackageId>Serilog.Sinks.MSSqlServer</PackageId>
15+
<PackageTags>serilog;sinks;mssqlserver</PackageTags>
16+
<PackageIconUrl>http://serilog.net/images/serilog-sink-nuget.png</PackageIconUrl>
17+
<PackageProjectUrl>https://github.com/serilog/serilog-sinks-mssqlserver</PackageProjectUrl>
18+
<PackageLicenseUrl>http://www.apache.org/licenses/LICENSE-2.0</PackageLicenseUrl>
19+
<RuntimeIdentifiers>win</RuntimeIdentifiers>
20+
<GenerateAssemblyTitleAttribute>false</GenerateAssemblyTitleAttribute>
21+
<GenerateAssemblyDescriptionAttribute>false</GenerateAssemblyDescriptionAttribute>
22+
<GenerateAssemblyCopyrightAttribute>false</GenerateAssemblyCopyrightAttribute>
23+
</PropertyGroup>
24+
25+
<ItemGroup>
26+
<PackageReference Include="Serilog" Version="2.5.0" />
27+
<PackageReference Include="Serilog.Sinks.PeriodicBatching" Version="2.1.1" />
28+
</ItemGroup>
29+
30+
<PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard2.0'">
31+
<DefineConstants>NETCORE;NETSTANDARD;NETSTANDARD2_0</DefineConstants>
32+
</PropertyGroup>
33+
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0'">
34+
<PackageReference Include="System.Data.SqlClient" Version="4.4.0" />
35+
<PackageReference Include="System.Configuration.ConfigurationManager" Version="4.4.0" />
36+
</ItemGroup>
37+
38+
<ItemGroup Condition=" '$(TargetFramework)' == 'net45' ">
39+
<Reference Include="System.Data" />
40+
<Reference Include="System.Xml" />
41+
<Reference Include="System.Xml.Linq" />
42+
<Reference Include="System.Configuration" />
43+
<Reference Include="System" />
44+
<Reference Include="Microsoft.CSharp" />
45+
</ItemGroup>
46+
47+
<ItemGroup Condition=" '$(TargetFramework)' == 'net452' ">
48+
<Reference Include="System.Data" />
49+
<Reference Include="System.Xml" />
50+
<Reference Include="System.Xml.Linq" />
51+
<Reference Include="System.Configuration" />
52+
<Reference Include="System" />
53+
<Reference Include="Microsoft.CSharp" />
54+
</ItemGroup>
55+
56+
</Project>

src/Serilog.Sinks.MSSqlServer/Serilog.Sinks.MSSqlServer.xproj

Lines changed: 0 additions & 17 deletions
This file was deleted.

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,11 @@ public PropertiesColumnOptions()
207207
/// If true, will use the property key as the element name.
208208
/// </summary>
209209
public bool UsePropertyKeyAsElementName { get; set; }
210+
211+
/// <summary>
212+
/// If set, will only store properties allowed by the filter.
213+
/// </summary>
214+
public Predicate<string> PropertiesFilter { get; set; }
210215
}
211216

212217
/// <summary>

src/Serilog.Sinks.MSSqlServer/Sinks/MSSqlServer/MSSqlServerSink.cs

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public class MSSqlServerSink : PeriodicBatchingSink
4545

4646
readonly string _connectionString;
4747

48-
readonly DataTable _eventsTable;
48+
private DataTable _eventsTable;
4949
readonly IFormatProvider _formatProvider;
5050
readonly string _tableName;
5151
readonly string _schemaName;
@@ -303,6 +303,18 @@ private string ConvertPropertiesToXmlStructure(IEnumerable<KeyValuePair<string,
303303
if (options.ExcludeAdditionalProperties)
304304
properties = properties.Where(p => !_additionalDataColumnNames.Contains(p.Key));
305305

306+
if (options.PropertiesFilter != null)
307+
{
308+
try
309+
{
310+
properties = properties.Where(p => options.PropertiesFilter(p.Key));
311+
}
312+
catch (Exception ex)
313+
{
314+
SelfLog.WriteLine("Unable to filter properties to store in {0} due to following error: {1}", this, ex);
315+
}
316+
}
317+
306318
var sb = new StringBuilder();
307319

308320
sb.AppendFormat("<{0}>", options.RootElementName);
@@ -411,10 +423,13 @@ private static bool TryChangeType(object obj, Type type, out object conversion)
411423
/// <param name="disposing"></param>
412424
protected override void Dispose(bool disposing)
413425
{
426+
base.Dispose(disposing);
427+
414428
if (_eventsTable != null)
429+
{
415430
_eventsTable.Dispose();
416-
417-
base.Dispose(disposing);
431+
_eventsTable = null;
432+
}
418433
}
419434
}
420435
}

0 commit comments

Comments
 (0)