Skip to content

Commit bf1f5e6

Browse files
authored
Merge pull request #496 from serilog-mssql/dev
Release 6.4.0
2 parents e85fbb0 + 357f24d commit bf1f5e6

26 files changed

+98
-39
lines changed

CHANGES.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# 6.4.0
2+
* Implemented #436: Truncate additional columns (thanks to @nhart12)
3+
* Fixed issue #489: allow varchar on standard columns (thanks to @nhart12)
4+
15
# 6.3.0
26
* Implemented #360: Automatic DB creation
37

Directory.Packages.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
44
</PropertyGroup>
55
<ItemGroup>
6+
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
67
<PackageVersion Include="System.Configuration.ConfigurationManager" Version="6.0.1" />
78
<PackageVersion Include="System.Collections" Version="4.3.0" />
89
<PackageVersion Include="System.IO.FileSystem.Primitives" Version="4.3.0" />

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,7 @@ The content of this column is rendered as JSON by default or with a custom IText
512512

513513
## Custom Property Columns
514514

515-
By default, any log event properties you include in your log statements will be saved to the XML `Properties` column or the JSON `LogEvent` column. But they can also be stored in their own individual columns via the `AdditionalColumns` collection. This adds overhead to write operations but is very useful for frequently-queried properties. Only `ColumnName` is required; the default configuration is `varchar(max)`.
515+
By default, any log event properties you include in your log statements will be saved to the XML `Properties` column or the JSON `LogEvent` column. But they can also be stored in their own individual columns via the `AdditionalColumns` collection. This adds overhead to write operations but is very useful for frequently-queried properties. Only `ColumnName` is required; the default configuration is `varchar(max)`. If you specify a DataLength on a column of character data types (NVarChar, VarChar, Char, NChar) the string will be automatically truncated to the datalength to fit in the column.
516516

517517
```csharp
518518
var columnOptions = new ColumnOptions

src/Serilog.Sinks.MSSqlServer/Configuration/Extensions/Hybrid/LoggerConfigurationMSSqlServerExtensions.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2020 Serilog Contributors
1+
// Copyright 2023 Serilog Contributors
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
1515
using System;
1616
using Microsoft.Extensions.Configuration;
1717
using Serilog.Configuration;
18-
using Serilog.Core;
1918
using Serilog.Debugging;
2019
using Serilog.Events;
2120
using Serilog.Formatting;

src/Serilog.Sinks.MSSqlServer/Configuration/Extensions/Microsoft.Extensions.Configuration/LoggerConfigurationMSSqlServerExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2020 Serilog Contributors
1+
// Copyright 2023 Serilog Contributors
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.

src/Serilog.Sinks.MSSqlServer/Extensions/StringExtensions.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ namespace Serilog.Sinks.MSSqlServer.Extensions
44
{
55
internal static class StringExtensions
66
{
7+
public static string TruncateOutput(this string value, int dataLength) =>
8+
dataLength < 0
9+
? value // No need to truncate if length set to maximum
10+
: value.Truncate(dataLength, "...");
11+
712
public static string Truncate(this string value, int maxLength, string suffix)
813
{
914
if (value == null) return null;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<Description>A Serilog sink that writes events to Microsoft SQL Server</Description>
5-
<VersionPrefix>6.3.0</VersionPrefix>
5+
<VersionPrefix>6.4.0</VersionPrefix>
66
<Authors>Michiel van Oudheusden;Christian Kadluba;Serilog Contributors</Authors>
77
<TargetFrameworks>netstandard2.0;net462;net472;net6.0</TargetFrameworks>
88
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ public ExceptionColumnOptions() : base()
2727
get => base.DataType;
2828
set
2929
{
30-
if (value != SqlDbType.NVarChar)
31-
throw new ArgumentException("The Standard Column \"Exception\" must be NVarChar.");
30+
if (!SqlDataTypes.VariableCharacterColumnTypes.Contains(value))
31+
throw new ArgumentException("The Standard Column \"Exception\" must be NVarChar or VarChar.");
3232
base.DataType = value;
3333
}
3434
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ public LevelColumnOptions() : base()
2828
get => base.DataType;
2929
set
3030
{
31-
if (value != SqlDbType.NVarChar && value != SqlDbType.TinyInt)
32-
throw new ArgumentException("The Standard Column \"Level\" must be of data type NVarChar or TinyInt.");
31+
if (!SqlDataTypes.VariableCharacterColumnTypes.Contains(value) && value != SqlDbType.TinyInt)
32+
throw new ArgumentException("The Standard Column \"Level\" must be of data type NVarChar, VarChar or TinyInt.");
3333
base.DataType = value;
3434
}
3535
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ public LogEventColumnOptions() : base()
2727
get => base.DataType;
2828
set
2929
{
30-
if (value != SqlDbType.NVarChar)
31-
throw new ArgumentException("The Standard Column \"LogEvent\" must be NVarChar.");
30+
if (!SqlDataTypes.VariableCharacterColumnTypes.Contains(value))
31+
throw new ArgumentException("The Standard Column \"LogEvent\" must be NVarChar or VarChar.");
3232
base.DataType = value;
3333
}
3434
}

0 commit comments

Comments
 (0)