Skip to content

Commit

Permalink
Merge pull request #52 from datalust/dev
Browse files Browse the repository at this point in the history
6.1.0 Release
  • Loading branch information
nblumhardt authored Aug 9, 2022
2 parents d9a9039 + 06d2978 commit 3599831
Show file tree
Hide file tree
Showing 143 changed files with 65,137 additions and 14,419 deletions.
4 changes: 2 additions & 2 deletions Build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ foreach ($src in ls src/*) {
echo "build: Packaging project in $src"

if ($suffix) {
& dotnet pack -c Release -o ..\..\artifacts --version-suffix=$suffix --include-source
& dotnet pack -c Release -o ..\..\artifacts --version-suffix=$suffix
} else {
& dotnet pack -c Release -o ..\..\artifacts --include-source
& dotnet pack -c Release -o ..\..\artifacts
}

if($LASTEXITCODE -ne 0) { exit 1 }
Expand Down
34 changes: 19 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,20 @@ This package makes it a one-liner to configure ASP.NET Core logging with Seq.

### Getting started

The instructions that follow are for **.NET Core 2.0+**.
The instructions that follow are for **.NET 6.0+** web applications.

Add [the NuGet package](https://nuget.org/packages/seq.extensions.logging) to your project either by editing the CSPROJ file, or using the NuGet package manager:

```
dotnet add package Seq.Extensions.Logging
```

In `Startup.cs`, call `AddSeq()` on the provided `ILoggingBuilder`.
In `Program.cs`, call `AddSeq()` on the host's `ILoggingBuilder`.

```csharp
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
// Added; requires `using Microsoft.Extensions.Logging;`
services.AddLogging(builder => builder.AddSeq())

// Other configuration follows...
}
}
// Use the Seq logging configuration in appsettings.json
builder.Host.ConfigureLogging(loggingBuilder =>
loggingBuilder.AddSeq());
```

The framework will inject `ILogger` instances into controllers and other classes:
Expand All @@ -54,7 +47,7 @@ class HomeController : Controller

Log messages will be sent to Seq in batches and be visible in the Seq user interface. Observe that correlation identifiers added by the framework, like `RequestId`, are all exposed and fully-searchable in Seq.

### Logging with message templates
### Logging with message templates~~~~

Seq supports the templated log messages used by _Microsoft.Extensions.Logging_. By writing events with _named format placeholders_, the data attached to the event preserves the individual property values.

Expand Down Expand Up @@ -109,7 +102,17 @@ In `appsettings.json` add a `"Seq"` property to `"Logging"` to configure the ser

### Dynamic log level control

The logging provider will dynamically adjust the default logging level up or down based on the level associated with an API key in Seq. For further information see the [Seq documentation](http://docs.datalust.co/docs/using-serilog#dynamic-level-control).
The logging provider will dynamically adjust the default logging level up or down based on the level associated with an API key in Seq. For further information see
the [Seq documentation](http://docs.datalust.co/docs/using-serilog#dynamic-level-control).

### Including literal JSON strings in log events

The logging provider ships with a `JsonSafeString` type that can be used to communicate to the logger that a string contains valid JSON, which can be safely included in a log event as structured data.

```csharp
var json = "{\"A\": 42}";
_logger.LogInformation("The answer is {Answer}", new JsonSafeString(json));
```

### Troubleshooting

Expand Down Expand Up @@ -149,7 +152,8 @@ Seq.Extensions.Logging.SelfLog.Enable(message => {

### Migrating to Serilog

This package is based on a subset of the powerful [Serilog](https://serilog.net) library. Not all of the options supported by the Serilog and Seq client libraries are present in the _Seq.Extensions.Logging_ package. Migrating to the full Serilog API however is very easy:
This package is based on a subset of the powerful [Serilog](https://serilog.net) library. Not all of the options supported by the Serilog and Seq client libraries are present in
the _Seq.Extensions.Logging_ package. Migrating to the full Serilog API however is very easy:

1. Install packages _Serilog_, _Serilog.Extensions.Logging_ and _Serilog.Sinks.Seq_.
2. Follow the instructions [here](https://github.com/serilog/serilog-extensions-logging) to change `AddSeq()` into `AddSerilog()` with a `LoggerConfiguration` object passed in
Expand Down
4 changes: 2 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
version: '{build}'
skip_tags: true
image: Visual Studio 2019
image: Visual Studio 2022
build_script:
- ps: ./Build.ps1
test: off
Expand All @@ -9,7 +9,7 @@ artifacts:
deploy:
- provider: NuGet
api_key:
secure: QYBIGd/prsJud8qlJati9FdnXbiA0VvyxO1z0TUiQV3svdpbD7ZaykJFTYKyIdQq
secure: 5aOb6I5NRP86KkV7nlAJmgyeuXXcrkWjZZZBPCZ7kAnw33ibgSMLdoGph3NMo0Xf
skip_symbols: true
on:
branch: /^(main|dev)$/
23 changes: 0 additions & 23 deletions example/ConsoleApplication/Program.cs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\Seq.Extensions.Logging\Seq.Extensions.Logging.csproj" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="6.0.0" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging" Version="3.0.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="3.0.1" />
<ProjectReference Include="..\..\src\Seq.Extensions.Logging\Seq.Extensions.Logging.csproj" />
</ItemGroup>

</Project>
12 changes: 12 additions & 0 deletions example/ConsoleExample/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;

using var services = new ServiceCollection()
.AddLogging(builder => builder
.AddConsole()
.AddSeq())
.BuildServiceProvider();

var logger = services.GetRequiredService<ILogger<Program>>();

logger.LogInformation("Hello, {Name}!", Environment.UserName);
3 changes: 0 additions & 3 deletions example/WebApplication/.bowerrc

This file was deleted.

54 changes: 0 additions & 54 deletions example/WebApplication/Controllers/HomeController.cs

This file was deleted.

18 changes: 0 additions & 18 deletions example/WebApplication/Program.cs

This file was deleted.

Loading

0 comments on commit 3599831

Please sign in to comment.