Skip to content

Commit

Permalink
Merge pull request #142 from serilog/dev
Browse files Browse the repository at this point in the history
5.0.0 Release
  • Loading branch information
nblumhardt authored Feb 11, 2021
2 parents 4d3ae18 + 4bb5963 commit f705cec
Show file tree
Hide file tree
Showing 29 changed files with 428 additions and 580 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -185,5 +185,7 @@ UpgradeLog*.htm

# Microsoft Fakes
FakesAssemblies/

*.orig
/sample/Sample/logs/
.idea
2 changes: 1 addition & 1 deletion Build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ if(Test-Path .\artifacts) { Remove-Item .\artifacts -Force -Recurse }

$branch = @{ $true = $env:APPVEYOR_REPO_BRANCH; $false = $(git symbolic-ref --short -q HEAD) }[$env:APPVEYOR_REPO_BRANCH -ne $NULL];
$revision = @{ $true = "{0:00000}" -f [convert]::ToInt32("0" + $env:APPVEYOR_BUILD_NUMBER, 10); $false = "local" }[$env:APPVEYOR_BUILD_NUMBER -ne $NULL];
$suffix = @{ $true = ""; $false = "$branch-$revision"}[$branch -eq "master" -and $revision -ne "local"]
$suffix = @{ $true = ""; $false = "$branch-$revision"}[$branch -eq "main" -and $revision -ne "local"]

foreach ($src in ls src/Serilog.*) {
Push-Location $src
Expand Down
41 changes: 27 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Serilog.Sinks.Seq [![Build status](https://ci.appveyor.com/api/projects/status/t7qdv68pej6inukl/branch/master?svg=true)](https://ci.appveyor.com/project/serilog/serilog-sinks-seq/branch/master) [![NuGet](https://img.shields.io/nuget/v/Serilog.Sinks.Seq.svg)](https://nuget.org/packages/serilog.sinks.seq) [![Join the chat at https://gitter.im/serilog/serilog](https://img.shields.io/gitter/room/serilog/serilog.svg)](https://gitter.im/serilog/serilog)

A Serilog sink that writes events to the [Seq](https://getseq.net) structured log server. Supports .NET 4.5+, .NET Core, and platforms compatible with the [.NET Platform Standard](https://github.com/dotnet/corefx/blob/master/Documentation/architecture/net-platform-standard.md) 1.1 including Windows 8 & UWP, Windows Phone and Xamarin.
A Serilog sink that writes events to the [Seq](https://datalust.co/seq) structured log server. Supports .NET 4.5+, .NET Core, and platforms compatible with the [.NET Platform Standard](https://github.com/dotnet/corefx/blob/master/Documentation/architecture/net-platform-standard.md) 1.1 including Windows 8 & UWP, Windows Phone and Xamarin.

[![Package Logo](http://serilog.net/images/serilog-sink-seq-nuget.png)](http://nuget.org/packages/serilog.sinks.seq)
[<img alt="Package Logo" src="https://datalust.co/images/seq-nuget.png" width="128px">](https://nuget.org/packages/serilog.sinks.seq)

### Getting started

Expand All @@ -28,15 +28,15 @@ Log.Error("Failed to log on user {ContactId}", contactId);

Then query log event properties like `ContactId` from the browser:

![Query in Seq](https://nblumhardt.github.io/images/seq-sink-screenshot.png)
![Query in Seq](https://raw.githubusercontent.com/serilog/serilog-sinks-seq/dev/assets/search-by-property.png)

When the application shuts down, [ensure any buffered events are propertly flushed to Seq](http://blog.merbla.com/2016/07/06/serilog-log-closeandflush/) by disposing the logger or calling `Log.CloseAndFlush()`:
When the application shuts down, [ensure any buffered events are propertly flushed to Seq](https://merbla.com/2016/07/06/serilog-log-closeandflush/) by disposing the logger or calling `Log.CloseAndFlush()`:

```csharp
Log.CloseAndFlush();
```

The sink can take advantage of Seq's [API keys](http://docs.getseq.net/docs/api-keys) to authenticate clients and dynamically attach properties to events at the server-side. To use an API key, specify it in the `apiKey` parameter of `WriteTo.Seq()`.
The sink can take advantage of Seq's [API keys](https://docs.datalust.co/docs/api-keys) to authenticate clients and dynamically attach properties to events at the server-side. To use an API key, specify it in the `apiKey` parameter of `WriteTo.Seq()`.

### XML `<appSettings>` configuration

Expand Down Expand Up @@ -130,16 +130,30 @@ The equivalent configuration in XML (Serilog 2.6+) is:
<add key="serilog:write-to:Seq.controlLevelSwitch" value="$controlSwitch" />
```

For further information see the [Seq documentation](http://docs.getseq.net/docs/using-serilog#dynamic-level-control).
The equivalent configuration in JSON is:

### Compact event format

Seq 3.3 accepts Serilog's more efficient [compact JSON format](https://github.com/serilog/serilog-formatting-compact/). To use this, configure the sink with `compact: true`:

```csharp
.WriteTo.Seq("http://localhost:5341", compact: true)
```json
{
"Serilog":
{
"LevelSwitches": { "$controlSwitch": "Information" },
"MinimumLevel": { "ControlledBy": "$controlSwitch" },
"WriteTo":
[{
"Name": "Seq",
"Args":
{
"serverUrl": "http://localhost:5341",
"apiKey": "yeEZyL3SMcxEKUijBjN",
"controlLevelSwitch": "$controlSwitch"
}
}]
}
}
```

For further information see the [Seq documentation](https://docs.datalust.co/docs/using-serilog#dynamic-level-control).

### Troubleshooting

> Nothing showed up, what can I do?
Expand Down Expand Up @@ -176,5 +190,4 @@ Serilog.Debugging.SelfLog.Enable(message => {
* Turn on the Serilog `SelfLog` as described above to check for connectivity problems and other issues on the client side.
* Make sure your application calls `Log.CloseAndFlush()`, or disposes the root `Logger`, before it exits - otherwise, buffered events may be lost.
* If your app is a Windows console application, it is also important to close the console window by exiting the app; Windows console apps are terminated "hard" if the close button in the title bar is used, so events buffered for sending to Seq may be lost if you use it.
* [Raise an issue](https://github.com/serilog/serilog-sinks-seq/issues), ask for help on the [Seq support forum](http://docs.getseq.net/discuss) or email **[email protected]**.

* [Raise an issue](https://github.com/serilog/serilog-sinks-seq/issues), ask for help on the [Seq support forum](https://docs.datalust.co/discuss) or email **[email protected]**.
10 changes: 4 additions & 6 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
version: '{build}'
skip_tags: true
image: Visual Studio 2017
configuration: Release
image: Visual Studio 2019
install:
- ps: mkdir -Force ".\build\" | Out-Null
build_script:
Expand All @@ -12,15 +11,14 @@ artifacts:
deploy:
- provider: NuGet
api_key:
secure: nvZ/z+pMS91b3kG4DgfES5AcmwwGoBYQxr9kp4XiJHj25SAlgdIxFx++1N0lFH2x
secure: K6TcIFIyxBcDuZ5DL7bJC+fGwDo458q0SDh+ybLujGTddA/voxg2FMUtJQ7rTEbt
skip_symbols: true
on:
branch: /^(master|dev)$/
branch: /^(main|dev)$/
- provider: GitHub
auth_token:
secure: p4LpVhBKxGS5WqucHxFQ5c7C8cP74kbNB0Z8k9Oxx/PMaDQ1+ibmoexNqVU5ZlmX
artifact: /Serilog.*\.nupkg/
tag: v$(appveyor_build_version)
on:
branch: master

branch: main
Binary file added assets/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/search-by-property.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions global.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"sdk": {
"version": "5.0.102"
}
}
2 changes: 1 addition & 1 deletion sample/Sample/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace Sample
{
public class Program
{
public static void Main(string[] args)
public static void Main()
{
// By sharing between the Seq sink and logger itself,
// Seq API keys can be used to control the level of the whole logging pipeline.
Expand Down
23 changes: 0 additions & 23 deletions sample/Sample/Properties/AssemblyInfo.cs

This file was deleted.

8 changes: 2 additions & 6 deletions sample/Sample/Sample.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<Description>Sample Console Application</Description>
<Authors>nblumhardt</Authors>
<TargetFrameworks>netcoreapp2.0;net47</TargetFrameworks>
<TargetFrameworks>netcoreapp3.1;net47</TargetFrameworks>
<AssemblyName>Sample</AssemblyName>
<OutputType>Exe</OutputType>
<PackageId>Sample</PackageId>
Expand All @@ -20,14 +20,10 @@
<PackageReference Include="Serilog.Sinks.Console" Version="3.1.0" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp2.0' ">
<PackageReference Include="System.Net.Http" Version="4.3.2" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net47' ">
<Reference Include="System.Net.Http" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\Serilog.Sinks.Seq\Serilog.Sinks.Seq.csproj" />
</ItemGroup>
Expand Down
1 change: 0 additions & 1 deletion serilog-sinks-seq.sln
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{037440DE-440
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "assets", "assets", "{E9D1B5E1-DEB9-4A04-8BAB-24EC7240ADAF}"
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
appveyor.yml = appveyor.yml
Build.ps1 = Build.ps1
README.md = README.md
Expand Down
13 changes: 13 additions & 0 deletions serilog-sinks-seq.sln.DotSettings
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:Boolean x:Key="/Default/UserDictionary/Words/=Backoff/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=delim/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=fdelim/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=filenames/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Formattable/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=HRESULT/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=oversized/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=ptoken/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=rdelim/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Seq_0027s/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Serilog/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Unextended/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
41 changes: 21 additions & 20 deletions src/Serilog.Sinks.Seq/SeqLoggerConfigurationExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
using Serilog.Events;
using Serilog.Sinks.Seq;
using System.Net.Http;
using Serilog.Sinks.PeriodicBatching;
using Serilog.Sinks.Seq.Audit;

#if DURABLE
Expand Down Expand Up @@ -57,9 +58,6 @@ public static class SeqLoggerConfigurationExtensions
/// <param name="retainedInvalidPayloadsLimitBytes">A soft limit for the number of bytes to use for storing failed requests.
/// The limit is soft in that it can be exceeded by any single error payload, but in that case only that single error
/// payload will be retained.</param>
/// <param name="compact">Use the compact log event format defined by
/// <a href="https://github.com/serilog/serilog-formatting-compact">Serilog.Formatting.Compact</a>. Has no effect on
/// durable log shipping. Requires Seq 3.3+.</param>
/// <param name="queueSizeLimit">The maximum number of events that will be held in-memory while waiting to ship them to
/// Seq. Beyond this limit, events will be dropped. The default is 100,000. Has no effect on
/// durable log shipping.</param>
Expand All @@ -78,7 +76,6 @@ public static LoggerConfiguration Seq(
LoggingLevelSwitch controlLevelSwitch = null,
HttpMessageHandler messageHandler = null,
long? retainedInvalidPayloadsLimitBytes = null,
bool compact = false,
int queueSizeLimit = SeqSink.DefaultQueueSizeLimit)
{
if (loggerSinkConfiguration == null) throw new ArgumentNullException(nameof(loggerSinkConfiguration));
Expand All @@ -89,21 +86,27 @@ public static LoggerConfiguration Seq(
throw new ArgumentOutOfRangeException(nameof(queueSizeLimit), "Queue size limit must be non-zero.");

var defaultedPeriod = period ?? SeqSink.DefaultPeriod;
var controlledSwitch = new ControlledLevelSwitch(controlLevelSwitch);

ILogEventSink sink;

if (bufferBaseFilename == null)
{
sink = new SeqSink(
var batchedSink = new SeqSink(
serverUrl,
apiKey,
batchPostingLimit,
defaultedPeriod,
eventBodyLimitBytes,
controlLevelSwitch,
messageHandler,
compact,
queueSizeLimit);
controlledSwitch,
messageHandler);

var options = new PeriodicBatchingSinkOptions
{
BatchSizeLimit = batchPostingLimit,
Period = defaultedPeriod,
QueueLimit = queueSizeLimit
};

sink = new PeriodicBatchingSink(batchedSink, options);
}
else
{
Expand All @@ -116,7 +119,7 @@ public static LoggerConfiguration Seq(
defaultedPeriod,
bufferSizeLimitBytes,
eventBodyLimitBytes,
controlLevelSwitch,
controlledSwitch,
messageHandler,
retainedInvalidPayloadsLimitBytes);
#else
Expand All @@ -125,7 +128,9 @@ public static LoggerConfiguration Seq(
#endif
}

return loggerSinkConfiguration.Sink(sink, restrictedToMinimumLevel);
return loggerSinkConfiguration.Conditional(
controlledSwitch.IsIncluded,
wt => wt.Sink(sink, restrictedToMinimumLevel));
}

/// <summary>
Expand All @@ -138,24 +143,20 @@ public static LoggerConfiguration Seq(
/// in order to write an event to the sink.</param>
/// <param name="apiKey">A Seq <i>API key</i> that authenticates the client to the Seq server.</param>
/// <param name="messageHandler">Used to construct the HttpClient that will send the log messages to Seq.</param>
/// <param name="compact">Use the compact log event format defined by
/// <a href="https://github.com/serilog/serilog-formatting-compact">Serilog.Formatting.Compact</a>. Has no effect on
/// durable log shipping. Requires Seq 3.3+.</param>
/// <returns>Logger configuration, allowing configuration to continue.</returns>
/// <exception cref="ArgumentNullException">A required parameter is null.</exception>
public static LoggerConfiguration Seq(
this LoggerAuditSinkConfiguration loggerAuditSinkConfiguration,
string serverUrl,
LogEventLevel restrictedToMinimumLevel = LevelAlias.Minimum,
string apiKey = null,
HttpMessageHandler messageHandler = null,
bool compact = false)
HttpMessageHandler messageHandler = null)
{
if (loggerAuditSinkConfiguration == null) throw new ArgumentNullException(nameof(loggerAuditSinkConfiguration));
if (serverUrl == null) throw new ArgumentNullException(nameof(serverUrl));

return loggerAuditSinkConfiguration.Sink(
new SeqAuditSink(serverUrl, apiKey, messageHandler, compact),
new SeqAuditSink(serverUrl, apiKey, messageHandler),
restrictedToMinimumLevel);
}
}
Expand Down
43 changes: 32 additions & 11 deletions src/Serilog.Sinks.Seq/Serilog.Sinks.Seq.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,42 @@

<PropertyGroup>
<Description>Serilog sink that writes to the Seq log server over HTTP/HTTPS.</Description>
<VersionPrefix>4.0.0</VersionPrefix>
<VersionPrefix>5.0.0</VersionPrefix>
<Authors>Serilog Contributors</Authors>
<Copyright>Copyright © Serilog Contributors 2013-2017</Copyright>
<TargetFrameworks>netstandard1.1;netstandard1.3;net45</TargetFrameworks>
<Copyright>Copyright © Serilog Contributors</Copyright>
<TargetFrameworks>netstandard1.1;netstandard1.3;net45;netstandard2.0;netcoreapp3.1;net5.0</TargetFrameworks>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<AssemblyName>Serilog.Sinks.Seq</AssemblyName>
<RootNamespace>Serilog</RootNamespace>
<AssemblyOriginatorKeyFile>../../assets/Serilog.snk</AssemblyOriginatorKeyFile>
<SignAssembly>true</SignAssembly>
<PublicSign Condition=" '$(OS)' != 'Windows_NT' ">true</PublicSign>
<PackageId>Serilog.Sinks.Seq</PackageId>
<PackageTags>serilog;seq</PackageTags>
<PackageIconUrl>https://serilog.net/images/serilog-sink-seq-nuget.png</PackageIconUrl>
<PackageIcon>icon.png</PackageIcon>
<PackageProjectUrl>https://github.com/serilog/serilog-sinks-seq</PackageProjectUrl>
<PackageLicenseUrl>http://www.apache.org/licenses/LICENSE-2.0</PackageLicenseUrl>
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
<RepositoryUrl>https://github.com/serilog/serilog-sinks-seq</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<GenerateAssemblyVersionAttribute>true</GenerateAssemblyVersionAttribute>
<LangVersion>8</LangVersion>
</PropertyGroup>

<PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard1.3' ">
<DefineConstants>$(DefineConstants);DURABLE;THREADING_TIMER</DefineConstants>
</PropertyGroup>

<PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
<DefineConstants>$(DefineConstants);DURABLE;THREADING_TIMER</DefineConstants>
</PropertyGroup>

<PropertyGroup Condition=" '$(TargetFramework)' == 'netcoreapp3.1' ">
<DefineConstants>$(DefineConstants);DURABLE;THREADING_TIMER</DefineConstants>
</PropertyGroup>

<PropertyGroup Condition=" '$(TargetFramework)' == 'net5.0' ">
<DefineConstants>$(DefineConstants);DURABLE;THREADING_TIMER</DefineConstants>
</PropertyGroup>

<PropertyGroup Condition=" '$(TargetFramework)' == 'net45' ">
<DefineConstants>$(DefineConstants);DURABLE;THREADING_TIMER;HRESULTS</DefineConstants>
</PropertyGroup>
Expand All @@ -34,17 +47,25 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Serilog" Version="2.5.0" />
<PackageReference Include="Serilog.Sinks.PeriodicBatching" Version="2.1.1" />
<PackageReference Include="Serilog.Formatting.Compact" Version="1.0.0" />
<PackageReference Include="Serilog" Version="2.10.0" />
<PackageReference Include="Serilog.Sinks.PeriodicBatching" Version="2.3.0" />
<PackageReference Include="Serilog.Formatting.Compact" Version="1.1.0" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard1.1' ">
<PackageReference Include="System.Net.Http" Version="4.3.2" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' != 'net45' ">
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard1.3' ">
<PackageReference Include="System.Net.Http" Version="4.3.2" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' != 'netstandard1.1' ">
<PackageReference Include="Serilog.Sinks.File" Version="4.0.0" />
</ItemGroup>

<ItemGroup>
<None Include="..\..\assets\icon.png" Pack="true" Visible="false" PackagePath="" />
</ItemGroup>

</Project>
Loading

0 comments on commit f705cec

Please sign in to comment.