Serilog.Sinks.MemorySink
0.1.0-alpha
This is a prerelease version of Serilog.Sinks.MemorySink.
There is a newer prerelease version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package Serilog.Sinks.MemorySink --version 0.1.0-alpha
NuGet\Install-Package Serilog.Sinks.MemorySink -Version 0.1.0-alpha
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Serilog.Sinks.MemorySink" Version="0.1.0-alpha" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Serilog.Sinks.MemorySink --version 0.1.0-alpha
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Serilog.Sinks.MemorySink, 0.1.0-alpha"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Serilog.Sinks.MemorySink as a Cake Addin #addin nuget:?package=Serilog.Sinks.MemorySink&version=0.1.0-alpha&prerelease // Install Serilog.Sinks.MemorySink as a Cake Tool #tool nuget:?package=Serilog.Sinks.MemorySink&version=0.1.0-alpha&prerelease
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
🧵 Serilog.Sinks.MemorySink
A Serilog sink that store log events in memory. You can retrieve these logs and render them in your own log viewer.
The sample app shows how to create a simple log viewer using WinUI 3.
✨Getting started
Install Serilog.Sinks.MemorySink:
dotnet add package Serilog.Sinks.MemorySink
Create a logger configuration:
Log.Logger = new LoggerConfiguration()
.WriteTo.MemorySink(out ILogSource<Serilog.Events.LogEvent> logSource)
.CreateLogger();
Retrieve logs:
var logs = await logSource.GetLogs(startIndex, count, cancellationToken);
⚙️Custom log item, options and exception handling
To use a custom log item, you need to provide a log event converter:
public record LogItem(DateTimeOffset Timestamp, LogEventLevel Level, string Message);
Log.Logger = new LoggerConfiguration()
.WriteTo.MemorySink(
out ILogSource<LogItem> logSource,
options =>
{
options.LogEventConverter = logEvent =>
{
return new LogItem(logEvent.Timestamp, logEvent.Level, logEvent.MessageTemplate.Text);
};
options.MaxLogsCount = 100_000;
options.OnException = ex =>
{
// Handle sink processing exception.
};
})
.CreateLogger();
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net6.0
- AsyncAwaitBestPractices (>= 7.0.0)
- Microsoft.Extensions.Options (>= 8.0.2)
- Serilog (>= 3.1.1)
-
net7.0
- AsyncAwaitBestPractices (>= 7.0.0)
- Microsoft.Extensions.Options (>= 8.0.2)
- Serilog (>= 3.1.1)
-
net8.0
- AsyncAwaitBestPractices (>= 7.0.0)
- Microsoft.Extensions.Options (>= 8.0.2)
- Serilog (>= 3.1.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
0.1.1-alpha | 118 | 4/26/2024 |
0.1.0-alpha | 74 | 4/19/2024 |