Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migration of MSSQL sink repo to new org #389

Merged
merged 3 commits into from
Feb 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/pr-validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: PR Validation

on:
pull_request:
branches: [ dev, master ]
branches: [ dev, main ]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
Expand All @@ -12,6 +12,6 @@ jobs:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2

- name: Run build and tests
run: ./Build.ps1
8 changes: 4 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Release

on:
push:
branches: [ dev, master ]
branches: [ dev, main ]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
Expand All @@ -12,7 +12,7 @@ jobs:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2

- name: Run build
run: ./Build.ps1 -SkipTests $true

Expand All @@ -24,7 +24,7 @@ jobs:
echo "Found version $versionMatch"

- name: Create GitHub releease
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sp. release

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, i merged too fast to catch this.

if: ${{ github.ref_name == 'master' }}
if: ${{ github.ref_name == 'main' }}
uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
Expand All @@ -33,7 +33,7 @@ jobs:
files: |
artifacts/*.nupkg
artifacts/*.snupkg

- name: Publish to nuget.org
env:
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
Expand Down
16 changes: 8 additions & 8 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
* Implemented Enhancement #182: configurable property names for custom columns (thanks to @rocknet for the contribution).
* Lots of refactoring and new unit tests.

# 5.3.0
# 5.3.0
Code quality release.
* Added code analysis and editorconfig rules based on Microsoft standards.
* Fixed code analysis errors where possible and added justified suppressions the few remainig.
Expand Down Expand Up @@ -63,22 +63,22 @@ Code quality release.

# 4.0.0
* Serilog 2.0
* [Documentation fix](https://github.com/serilog/serilog-sinks-mssqlserver/pull/32)
* [Documentation fix](https://github.com/serilog-mssql/serilog-sinks-mssqlserver/pull/32)

# 2.0.33
* Option added to exclude redundant properties from serialized JSON in column LogEvent. (https://github.com/serilog/serilog-sinks-mssqlserver/pull/27)
* Option added to exclude redundant properties from serialized JSON in column LogEvent. (https://github.com/serilog-mssql/serilog-sinks-mssqlserver/pull/27)

# 2.0.32
* Safe conversion of data types. Also included selflog for bulk operation errors. (https://github.com/serilog/serilog-sinks-mssqlserver/pull/4)
* Safe conversion of data types. Also included selflog for bulk operation errors. (https://github.com/serilog-mssql/serilog-sinks-mssqlserver/pull/4)

# 2.0.31
* Added the ability to configure additional columns via XML configuration (https://github.com/serilog/serilog-sinks-mssqlserver/pull/6)
* Added the ability to configure additional columns via XML configuration (https://github.com/serilog-mssql/serilog-sinks-mssqlserver/pull/6)

# 2.0.30
* You can optionally save the log event inside the database too. Also added ability to exclude the properties if they are saved already inside additional columns. (https://github.com/serilog/serilog-sinks-mssqlserver/pull/7)
* You can optionally save the log event inside the database too. Also added ability to exclude the properties if they are saved already inside additional columns. (https://github.com/serilog-mssql/serilog-sinks-mssqlserver/pull/7)

# 2.0.28
* Added explicit column mappings (https://github.com/serilog/serilog-sinks-mssqlserver/pull/10)
* Added explicit column mappings (https://github.com/serilog-mssql/serilog-sinks-mssqlserver/pull/10)

# 2.0.27
* Option added to automatically create a database table (by Kiran Varsani (https://github.com/varsanikp))
Expand All @@ -87,7 +87,7 @@ Code quality release.
* Ability to add additional properties as columns in the database

# 2.0.1
* Option to [write times in UTC](https://github.com/serilog/serilog-sinks-mssqlserver/pull/1)
* Option to [write times in UTC](https://github.com/serilog-mssql/serilog-sinks-mssqlserver/pull/1)

# 1.5
* Moved from serilog/serilog
52 changes: 26 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# 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)
# Serilog.Sinks.MSSqlServer ![Build & Test](https://github.com/serilog-mssql/serilog-sinks-mssqlserver/actions/workflows/pr-validation.yml/badge.svg) [![NuGet](https://img.shields.io/nuget/v/Serilog.Sinks.MSSqlServer.svg)](https://nuget.org/packages/Serilog.Sinks.MSSqlServer)

A Serilog sink that writes events to Microsoft SQL Server. This sink will write the log event data to a table and can optionally also store the properties inside an XML or JSON column so they can be queried. Important properties can also be written to their own separate columns.

Expand Down Expand Up @@ -147,7 +147,7 @@ var log = new LoggerConfiguration()

### Code + _System.Configuration_

Projects can load `MSSqlServerSinkOptions` and `ColumnOptions` objects from an XML configuration file such as `app.config` or `web.config`. The sink configuration method automatically checks `ConfigurationManager`, so there is no code to show, and no additional packages are required. See the [External Configuration Syntax](#external-configuration-syntax) topic for details.
Projects can load `MSSqlServerSinkOptions` and `ColumnOptions` objects from an XML configuration file such as `app.config` or `web.config`. The sink configuration method automatically checks `ConfigurationManager`, so there is no code to show, and no additional packages are required. See the [External Configuration Syntax](#external-configuration-syntax) topic for details.

### External using _Serilog.Settings.Configuration_

Expand Down Expand Up @@ -194,7 +194,7 @@ CREATE TABLE [Logs] (
[Exception] nvarchar(max) NULL,
[Properties] nvarchar(max) NULL

CONSTRAINT [PK_Logs] PRIMARY KEY CLUSTERED ([Id] ASC)
CONSTRAINT [PK_Logs] PRIMARY KEY CLUSTERED ([Id] ASC)
);
```

Expand Down Expand Up @@ -263,17 +263,17 @@ A flag specifiying if the log events table should be created if it does not exis

### BatchPostingLimit

Specifies a maximum number of log events that the non-audit sink writes per batch. The default is 50.
Specifies a maximum number of log events that the non-audit sink writes per batch. The default is 50.
This setting is not used by the audit sink as it writes each event immediately and not in a batched manner.

### BatchPeriod

Specifies the interval in which the non-audit sink writes a batch of log events to the database. It defaults to 5 seconds.
Specifies the interval in which the non-audit sink writes a batch of log events to the database. It defaults to 5 seconds.
This setting is not used by the audit sink as it writes each event immediately and not in a batched manner.

### EagerlyEmitFirstEvent

A Flag to eagerly write a batch to the database containing the first received event regardless of `BatchPostingLimit` or `BatchPeriod`. It defaults to `true`.
A Flag to eagerly write a batch to the database containing the first received event regardless of `BatchPostingLimit` or `BatchPeriod`. It defaults to `true`.
This setting is not used by the audit sink as it writes each event immediately and not in a batched manner.

### UseAzureManagedIdentity
Expand Down Expand Up @@ -537,21 +537,21 @@ In this example, when a log event contains any of the properties `UserName`, `Us

Unlike previous versions of the sink, Standard Column names are not reserved. If you remove the `Id` Standard Column from the `ColumnOptions.Store` list, you are free to create a new custom column called `Id` which the sink will treat like any other custom column fully under your control.

Note the use of the `SqlDbType` enumerations for specifying `DataType`. Unlike previous versions of the sink, .NET `System` data types and `DataColumn` objects are no longer used for custom column definition.
Note the use of the `SqlDbType` enumerations for specifying `DataType`. Unlike previous versions of the sink, .NET `System` data types and `DataColumn` objects are no longer used for custom column definition.

### Excluding redundant data

By default, properties matching a custom column will still be included in the data saved to the XML `Properties` or JSON `LogEvent` column. This is consistent with the idea behind structured logging, and makes it easier to convert the log data to another document-data storage platform later, if desired.
By default, properties matching a custom column will still be included in the data saved to the XML `Properties` or JSON `LogEvent` column. This is consistent with the idea behind structured logging, and makes it easier to convert the log data to another document-data storage platform later, if desired.

However, the properties being saved in their own columns can be excluded from these catch-all columns. Use the `columnOptions.Properties.ExcludeAdditionalProperties` parameter to exclude the redundant properties from the `Properties` XML column, or `columnOptions.LogEvent.ExcludeAdditionalProperties` if you're using the JSON `LogEvent` column.
However, the properties being saved in their own columns can be excluded from these catch-all columns. Use the `columnOptions.Properties.ExcludeAdditionalProperties` parameter to exclude the redundant properties from the `Properties` XML column, or `columnOptions.LogEvent.ExcludeAdditionalProperties` if you're using the JSON `LogEvent` column.

Standard Columns are always excluded from the XML `Properties` column but Standard Columns are included in the JSON data for backwards-compatibility reasons. They can be excluded from the JSON `LogEvent` column with `columnOptions.LogEvent.ExcludeStandardColumns`.

## External Configuration Syntax

Projects targeting frameworks which are compatible with _System.Configuration_ automatically have support for XML-based configuration (either `app.config` or `web.config`) of a `MSSqlServerSinkOptions` parameters and a `ColumnOptions` table definition, and the _Serilog.Settings.AppSettings_ package adds XML-based configuration of other direct sink arguments (like `customFormatter` or `restrictedToMinimumLevel`).

Projects targeting frameworks which are compatible with _Microsoft.Extensions.Configuration_ can apply configuration-driven sink setup and `MSSqlServerSinkOptions` or `ColumnOptions` settings using the _Serilog.Settings.Configuration_ package or by supplying the appropriate arguments through code.
Projects targeting frameworks which are compatible with _Microsoft.Extensions.Configuration_ can apply configuration-driven sink setup and `MSSqlServerSinkOptions` or `ColumnOptions` settings using the _Serilog.Settings.Configuration_ package or by supplying the appropriate arguments through code.

All properties of the `MSSqlServerSinkOptions` class are configurable and almost all of the `ColumnOptions` class except the `Properties.PropertyFilter` predicate expression, and all elements and lists shown are optional. In most cases configuration key names match the class property names, but there are some exceptions. For example, because `PrimaryKey` is a `SqlColumn` object reference when configured through code, external configuration uses a `primaryKeyColumnName` setting to identify the primary key by name.

Expand All @@ -571,8 +571,8 @@ Keys and values are not case-sensitive. This is an example of configuring the si
"Using": ["Serilog.Sinks.MSSqlServer"],
"MinimumLevel": "Debug",
"WriteTo": [
{ "Name": "MSSqlServer",
"Args": {
{ "Name": "MSSqlServer",
"Args": {
"connectionString": "NamedConnectionString",
"sinkOptionsSection": {
"tableName": "Logs",
Expand All @@ -583,7 +583,7 @@ Keys and values are not case-sensitive. This is an example of configuring the si
},
"restrictedToMinimumLevel": "Warning",
"columnOptionsSection": { . . . }
}
}
}
]
}
Expand Down Expand Up @@ -612,15 +612,15 @@ As the name suggests, `columnOptionSection` is an entire configuration section i
],
"id": { "nonClusteredIndex": true },
"level": { "columnName": "Severity", "storeAsEnum": false },
"properties": {
"properties": {
"columnName": "Properties",
"excludeAdditionalProperties": true,
"excludeAdditionalProperties": true,
"dictionaryElementName": "dict",
"itemElementName": "item",
"omitDictionaryContainerElement": false,
"omitSequenceContainerElement": false,
"omitStructureContainerElement": false,
"omitElementIfEmpty": true,
"omitDictionaryContainerElement": false,
"omitSequenceContainerElement": false,
"omitStructureContainerElement": false,
"omitElementIfEmpty": true,
"propertyElementName": "prop",
"rootElementName": "root",
"sequenceElementName": "seq",
Expand Down Expand Up @@ -667,9 +667,9 @@ Keys and values are case-sensitive. Case must match **_exactly_** as shown below
</RemoveStandardColumns>
<Columns>
<add ColumnName="EventType" DataType="int"/>
<add ColumnName="EnvironmentUserName"
PropertyName="UserName"
DataType="varchar"
<add ColumnName="EnvironmentUserName"
PropertyName="UserName"
DataType="varchar"
DataLength="50" />
<add ColumnName="Release"
DataType="varchar"
Expand Down Expand Up @@ -698,7 +698,7 @@ Keys and values are case-sensitive. Case must match **_exactly_** as shown below
StructureElementName="struct"
UsePropertyKeyAsElementName="false"/>
<TimeStamp ConvertToUtc="true"/>
</MSSqlServerSettingsSection>
</MSSqlServerSettingsSection>
```

### XML Sink (_Serilog.Settings.AppSettings_)
Expand Down Expand Up @@ -738,15 +738,15 @@ When you exit an application running in debug mode under Visual Studio, normal s

### Try a `dev` package

If you're reading about a feature that doesn't seem to work, check whether you're reading the docs for the `master` branch or the `dev` branch -- most Serilog repositories are configured to use the `dev` branch by default. If you see something interesting only described by the `dev` branch documentation, you'll have to reference a `dev`-versioned package. The repository automatically generates a new `dev` package whenever code-related changes are merged.
If you're reading about a feature that doesn't seem to work, check whether you're reading the docs for the `main` branch or the `dev` branch -- most Serilog repositories are configured to use the `dev` branch by default. If you see something interesting only described by the `dev` branch documentation, you'll have to reference a `dev`-versioned package. The repository automatically generates a new `dev` package whenever code-related changes are merged.

### Are you really using this sink?

Please check your NuGet references and confirm you are specifically referencing _Serilog.Sinks.MSSqlServer_. In the early days of .NET Core, there was a popular Core-specific fork of this sink, but the documentation and NuGet project URLs pointed here. Today the package is marked deprecated, but we continue to see some confusion around this.

### .NET Framework apps must reference Microsoft.Data.SqlClient

If you are using the sink in a .NET Framework app, make sure to add a nuget package reference to Microsoft.Data.SqlClient in your app project. This is necessary due to a bug in SqlClient which can lead to exceptions about missing Microsoft assemblies. Details can be found in [issue 283](https://github.com/serilog/serilog-sinks-mssqlserver/issues/283#issuecomment-664397489) and [issue 208](https://github.com/serilog/serilog-sinks-mssqlserver/issues/208#issuecomment-664503566).
If you are using the sink in a .NET Framework app, make sure to add a nuget package reference to Microsoft.Data.SqlClient in your app project. This is necessary due to a bug in SqlClient which can lead to exceptions about missing Microsoft assemblies. Details can be found in [issue 283](https://github.com/serilog-mssql/serilog-sinks-mssqlserver/issues/283#issuecomment-664397489) and [issue 208](https://github.com/serilog-mssql/serilog-sinks-mssqlserver/issues/208#issuecomment-664503566).

## Querying Property Data

Expand Down Expand Up @@ -804,6 +804,6 @@ Feature | Notes
:--- | :---
`AdditionalDataColumns` | Use the `AdditionalColumns` collection instead. Configuring the sink no longer relies upon .NET `DataColumn` objects or .NET `System` types.
`Id.BigInt` | Use `Id.DataType = SqlDb.BigInt` instead. (The `BigInt` property was only available in dev packages).
`Binary` and `VarBinary` | Due to the way Serilog represents property data internally, it isn't possible for the sink to access property data as a byte array, so the sink can't write to these column types.
`Binary` and `VarBinary` | Due to the way Serilog represents property data internally, it isn't possible for the sink to access property data as a byte array, so the sink can't write to these column types.

Most deprecated features are still available, but they are marked with the `[Obsolete]` attribute (which results in a compiler warning in your project) and will be removed in a future release. You should switch to the replacement implementations as soon as possible. Where possible, internally these are converted to the replacement implementation so that they only exist at the configuration level.
27 changes: 0 additions & 27 deletions appveyor.yml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<Description>A Serilog sink that writes events to Microsoft SQL Server</Description>
<VersionPrefix>5.7.0</VersionPrefix>
<VersionPrefix>5.7.1</VersionPrefix>
<Authors>Michiel van Oudheusden;Christian Kadluba;Serilog Contributors</Authors>
<TargetFrameworks>netstandard2.0;net452;net462;net472;netcoreapp3.1</TargetFrameworks>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
Expand All @@ -14,9 +14,9 @@
<PackageId>Serilog.Sinks.MSSqlServer</PackageId>
<PackageTags>serilog;sinks;mssqlserver</PackageTags>
<PackageIcon>serilog-sink-nuget.png</PackageIcon>
<PackageProjectUrl>https://github.com/serilog/serilog-sinks-mssqlserver</PackageProjectUrl>
<PackageProjectUrl>https://github.com/serilog-mssql/serilog-sinks-mssqlserver</PackageProjectUrl>
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
<RepositoryUrl>https://github.com/serilog/serilog-sinks-mssqlserver</RepositoryUrl>
<RepositoryUrl>https://github.com/serilog-mssql/serilog-sinks-mssqlserver</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
Expand Down