Serilog.Formatting.Compact.Reader 3.0.0

The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org. Prefix Reserved
dotnet add package Serilog.Formatting.Compact.Reader --version 3.0.0
NuGet\Install-Package Serilog.Formatting.Compact.Reader -Version 3.0.0
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.Formatting.Compact.Reader" Version="3.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Serilog.Formatting.Compact.Reader --version 3.0.0
#r "nuget: Serilog.Formatting.Compact.Reader, 3.0.0"
#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.Formatting.Compact.Reader as a Cake Addin
#addin nuget:?package=Serilog.Formatting.Compact.Reader&version=3.0.0

// Install Serilog.Formatting.Compact.Reader as a Cake Tool
#tool nuget:?package=Serilog.Formatting.Compact.Reader&version=3.0.0

Serilog.Formatting.Compact.Reader Build status NuGet Pre Release

This package reads (deserializes) JSON log files created by Serilog.Formatting.Compact back into Serilog LogEvents.

Example

Log events are written to a file using CompactJsonFormatter:

using (var fileLog = new LoggerConfiguration()
    .WriteTo.File(new CompactJsonFormatter(), "log.clef")
    .CreateLogger())
{
    fileLog.Information("Hello, {@User}", new { Name = "nblumhardt", Id = 101 });
    fileLog.Information("Number {N:x8}", 42);
    fileLog.Warning("Tags are {Tags}", new[] { "test", "orange" });

    try
    {
        throw new DivideByZeroException();
    }
    catch(Exception ex)
    {
        fileLog.Error(ex, "Something failed");
    }
}

This creates a log file with content similar to:

{"@t":"2016-10-12T04:46:58.0554314Z","@mt":"Hello, {@User}","User":{"Name":"nblumhardt","Id":101}}
{"@t":"2016-10-12T04:46:58.0684369Z","@mt":"Number {N:x8}","@r":["0000002a"],"N":42}
{"@t":"2016-10-12T04:46:58.0724384Z","@mt":"Tags are {Tags}","@l":"Warning","Tags":["test","orange"]}
{"@t":"2016-10-12T04:46:58.0904378Z","@mt":"Something failed","@l":"Error", "@x":"System.DivideByZer...<snip>"}

An instance of LogEventReader converts each line of the log file back into a LogEvent, which can be manipulated, rendered, or written through another Serilog sink:

using (var console = new LoggerConfiguration()
    .WriteTo.LiterateConsole()
    .CreateLogger())
{
    using (var clef = File.OpenText("log.clef"))
    {
        var reader = new LogEventReader(clef);
        LogEvent evt;
        while (reader.TryRead(out evt))
            console.Write(evt);
    }
}

Output from the logger:

Screenshot

Limitations

Events deserialized from JSON are for typical purposes just like the original log events. There are two main things to keep in mind:

  1. JSON doesn't carry all of the type information necessary to determine if, for example, a number is an int or a float. JSON.NET does a good job of deserializing anything that it encounters, but you can't rely on the types here being identical.
  2. Exceptions deserialized this way aren't instances of the original exception type - all you can do with them is call ToString() to get the formatted message and stack trace, which is what 99% of Serilog sinks will do.
Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  net5.0-windows was computed.  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 was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 is compatible. 
.NET Framework net461 was computed.  net462 is compatible.  net463 was computed.  net47 was computed.  net471 is compatible.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (14)

Showing the top 5 NuGet packages that depend on Serilog.Formatting.Compact.Reader:

Package Downloads
Umbraco.Cms.Infrastructure The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org.

Contains the infrastructure assembly needed to run Umbraco CMS.

UmbracoCms.Core The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org.

Contains the core assemblies needed to run Umbraco Cms. This package only contains assemblies and can be used for package development. Use the UmbracoCms package to setup Umbraco in Visual Studio as an ASP.NET project.

Nuke.Build The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org.

The AKEless Build System for C#/.NET Signed by signpath.io from repository 'https://github.com/nuke-build/nuke' commit '011956b31c05f14f3233f6241cd6fbe038824d71' (see contained AppVeyorSettings.json file for build settings).

Serilog.AspNetCore.Ingestion

Package Description

OptimaJet.Logging

Base logger for the WorkflowServer and DWKit.

GitHub repositories (8)

Showing the top 5 popular GitHub repositories that depend on Serilog.Formatting.Compact.Reader:

Repository Stars
umbraco/Umbraco-CMS
The simple, flexible and friendly ASP.NET CMS used by more than 730.000 websites
nuke-build/nuke
🏗 The AKEless Build System for C#/.NET
ErsatzTV/ErsatzTV
Stream custom live channels using your own media
SparkDevNetwork/Rock
An open source CMS, Relationship Management System (RMS) and Church Management System (ChMS) all rolled into one.
leekelleher/umbraco-contentment
Contentment for Umbraco - a state of happiness and satisfaction
Version Downloads Last updated
3.0.0 393,553 11/9/2023
3.0.0-dev-00063 173 10/3/2023
2.0.0 2,103,397 11/3/2022
2.0.0-dev-00060 161 10/30/2022
1.0.6-dev-00059 156 10/28/2022
1.0.5 9,652,144 4/29/2021
1.0.5-dev-00048 290 4/27/2021
1.0.4 29,701 3/8/2021
1.0.3 1,738,680 11/5/2018
1.0.3-dev-00036 1,062 9/22/2018
1.0.3-dev-00034 1,067 5/9/2018
1.0.3-dev-00033 1,016 3/21/2018
1.0.2 87,669 2/5/2018
1.0.2-dev-00024 974 8/29/2017
1.0.2-dev-00020 907 8/21/2017
1.0.1 2,743 5/18/2017
1.0.1-dev-00016 963 5/18/2017
1.0.1-dev-00014 962 5/18/2017
1.0.0 2,968 2/14/2017
1.0.0-dev-00010 1,028 11/25/2016
1.0.0-dev-00008 1,063 10/28/2016
1.0.0-dev-00006 954 10/27/2016
1.0.0-dev-00004 958 10/27/2016
1.0.0-dev-00002 926 10/18/2016
1.0.0-dev-00001 951 10/12/2016