Skip to content

Commit

Permalink
Merge pull request #190 from datalust/dev
Browse files Browse the repository at this point in the history
5.2.2 Release
  • Loading branch information
nblumhardt authored Nov 15, 2022
2 parents 5cd6dfd + f8e7b73 commit 5fa0759
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 40 deletions.
58 changes: 24 additions & 34 deletions sample/Sample/Program.cs
Original file line number Diff line number Diff line change
@@ -1,46 +1,36 @@
using System;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Serilog;
using Serilog.Core;

namespace Sample
{
public static class Program
{
public static async Task 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.
var levelSwitch = new LoggingLevelSwitch();
// By sharing between the Seq sink and logger itself,
// Seq API keys can be used to control the level of the whole logging pipeline.
var levelSwitch = new LoggingLevelSwitch();

try
{
Log.Logger = new LoggerConfiguration()
.MinimumLevel.ControlledBy(levelSwitch)
.WriteTo.Console()
.WriteTo.Seq("http://localhost:5341", controlLevelSwitch: levelSwitch)
.CreateLogger();
try
{
Log.Logger = new LoggerConfiguration()
.MinimumLevel.ControlledBy(levelSwitch)
.WriteTo.Console()
.WriteTo.Seq("http://localhost:5341", controlLevelSwitch: levelSwitch)
.CreateLogger();

Log.Information("Sample starting up");
Log.Information("Sample starting up");

foreach (var i in Enumerable.Range(0, 100))
{
Log.Information("Running loop {Counter}, switch is at {Level}", i, levelSwitch.MinimumLevel);
foreach (var i in Enumerable.Range(0, 100))
{
Log.Information("Running loop {Counter}, switch is at {Level}", i, levelSwitch.MinimumLevel);

Thread.Sleep(1000);
Log.Debug("Loop iteration done");
}
}
catch (Exception ex)
{
Log.Error(ex, "Unhandled exception");
}
finally
{
await Log.CloseAndFlushAsync();
}
}
Thread.Sleep(1000);
Log.Debug("Loop iteration done");
}
}
catch (Exception ex)
{
Log.Error(ex, "Unhandled exception");
}
finally
{
await Log.CloseAndFlushAsync();
}
6 changes: 1 addition & 5 deletions sample/Sample/Sample.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net4.8;net5.0</TargetFrameworks>
<TargetFramework>net6.0</TargetFramework>
<OutputType>Exe</OutputType>
<LangVersion>latest</LangVersion>
<Nullable>enable</Nullable>
Expand All @@ -10,10 +10,6 @@
<ItemGroup>
<PackageReference Include="Serilog.Sinks.Console" Version="4.1.0" />
</ItemGroup>

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

<ItemGroup>
<ProjectReference Include="..\..\src\Serilog.Sinks.Seq\Serilog.Sinks.Seq.csproj" />
Expand Down
2 changes: 1 addition & 1 deletion src/Serilog.Sinks.Seq/Serilog.Sinks.Seq.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<Description>Serilog sink that writes to the Seq log server over HTTP/HTTPS.</Description>
<VersionPrefix>5.2.1</VersionPrefix>
<VersionPrefix>5.2.2</VersionPrefix>
<Authors>Serilog Contributors</Authors>
<Copyright>Copyright © Serilog Contributors</Copyright>
<TargetFrameworks>net5.0;netstandard1.1;netstandard1.3;netstandard2.0;net4.5;netcoreapp3.1</TargetFrameworks>
Expand Down
4 changes: 4 additions & 0 deletions src/Serilog.Sinks.Seq/Sinks/Seq/Http/SeqIngestionApiClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

using System;
using System.Net.Http;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using Serilog.Events;
Expand All @@ -38,6 +39,9 @@ public SeqIngestionApiClient(string serverUrl, string? apiKey, HttpMessageHandle
_apiKey = apiKey;
_httpClient = messageHandler != null
? new HttpClient(messageHandler)
: RuntimeInformation.IsOSPlatform(OSPlatform.Create("WEBASSEMBLY"))
// Can't set PooledConnectionLifetime on this platform
? new HttpClient()
:
#if SOCKETS_HTTP_HANDLER_ALWAYS_DEFAULT
new HttpClient(new SocketsHttpHandler
Expand Down

0 comments on commit 5fa0759

Please sign in to comment.