Serilog.Formatting.Compact.Reader 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.

Showing the top 20 packages that depend on Serilog.Formatting.Compact.Reader.

Packages Downloads
Nuke.Build
The AKEless Build System for C#/.NET Signed by signpath.io from repository 'https://github.com/nuke-build/nuke' commit '369ef2b8fd696c639b333812edf5c5fdd5f3e7e6' (see contained AppVeyorSettings.json file for build settings).
25
Nuke.Build
The AKEless Build System for C#/.NET Signed by signpath.io from repository 'https://github.com/nuke-build/nuke' commit 'd8ff60a63e8e7bb77b64c9820c42add96835772d' (see contained AppVeyorSettings.json file for build settings).
22
Nuke.Common
Cross-platform build automation system Signed by signpath.io from repository 'https://github.com/nuke-build/nuke' commit '39132f3fb1fea9f889894dfe520cf4434d6eca4e' (see contained AppVeyorSettings.json file for build settings).
21
Nuke.Build
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).
21
Nuke.Build
Cross-platform build automation system Signed by signpath.io from repository 'https://github.com/nuke-build/nuke' commit '46bbe7900f7f6426f377c713dd11d76e37516bc3' (see contained AppVeyorSettings.json file for build settings).
21
Nuke.Build
The AKEless Build System for C#/.NET Signed by signpath.io from repository 'https://github.com/nuke-build/nuke' commit 'ea86450b4db1568563b15122f0250495fd55776e' (see contained AppVeyorSettings.json file for build settings).
21
Nuke.Build
The AKEless Build System for C#/.NET Signed by signpath.io from repository 'https://github.com/nuke-build/nuke' commit 'aeacff85068cb9218354491b39fbf916e5ea28e8' (see contained AppVeyorSettings.json file for build settings).
21
Nuke.Build
The AKEless Build System for C#/.NET Signed by signpath.io from repository 'https://github.com/nuke-build/nuke' commit 'bbceff250ec4c9c604b33b38600ab9b4a4e17dac' (see contained AppVeyorSettings.json file for build settings).
19
Nuke.Common
Cross-platform build automation system Signed by signpath.io from repository 'https://github.com/nuke-build/nuke' commit 'fa8aae50ade3b7479a059fcd775fd4dc1a108220' (see contained AppVeyorSettings.json file for build settings).
18
Nuke.Build
The AKEless Build System for C#/.NET Signed by signpath.io from repository 'https://github.com/nuke-build/nuke' commit 'cda28e5941e47b2b2a3d9bea20f78d11af1d92e0' (see contained AppVeyorSettings.json file for build settings).
18
Nuke.Common
Cross-platform build automation system Signed by signpath.io from repository 'https://github.com/nuke-build/nuke' commit '1b7919295cb9cac9eccc00871c6d1b8bc1bed375' (see contained AppVeyorSettings.json file for build settings).
17
Nuke.Build
The AKEless Build System for C#/.NET Signed by signpath.io from repository 'https://github.com/nuke-build/nuke' commit 'f6123b1450735fa0fc6dd2713b40f23019f470b1' (see contained AppVeyorSettings.json file for build settings).
17
Nuke.Build
The AKEless Build System for C#/.NET Signed by signpath.io from repository 'https://github.com/nuke-build/nuke' commit '245ccadae9fc856bef1b7c929958e3230fd1f729' (see contained AppVeyorSettings.json file for build settings).
15
Nuke.Build
The AKEless Build System for C#/.NET Signed by signpath.io from repository 'https://github.com/nuke-build/nuke' commit 'a94fbe2ca0c12a4bf2df0a4c92e9dc51ee8f1076' (see contained AppVeyorSettings.json file for build settings).
15
Nuke.Build
Cross-platform build automation system Signed by signpath.io from repository 'https://github.com/nuke-build/nuke' commit '4667694d0480c8fc8fcc027d7dab8566d3f4dfcd' (see contained AppVeyorSettings.json file for build settings).
14
Nuke.Build
The AKEless Build System for C#/.NET Signed by signpath.io from repository 'https://github.com/nuke-build/nuke' commit '9ced2aa3a6cecfbea5ef45d692ef7f156da0dbe0' (see contained AppVeyorSettings.json file for build settings).
14
Nuke.Build
The AKEless Build System for C#/.NET Signed by signpath.io from repository 'https://github.com/nuke-build/nuke' commit '1688d821b6cef6e19f869ca665d7b0ba4c33255a' (see contained AppVeyorSettings.json file for build settings).
14
Nuke.Build
The AKEless Build System for C#/.NET Signed by signpath.io from repository 'https://github.com/nuke-build/nuke' commit 'a20c3b752d0c9f533a6e2c21fee6325032cd3d70' (see contained AppVeyorSettings.json file for build settings).
14
Nuke.Build
The AKEless Build System for C#/.NET Signed by signpath.io from repository 'https://github.com/nuke-build/nuke' commit 'e782a00085e84e022c341a265b54c0c9308cbe78' (see contained AppVeyorSettings.json file for build settings).
13
Nuke.Build
The AKEless Build System for C#/.NET Signed by signpath.io from repository 'https://github.com/nuke-build/nuke' commit '45063fd8e8531a3146ee64c9d93f1d3360062c29' (see contained AppVeyorSettings.json file for build settings).
13

.NET Framework 4.6.2

.NET Standard 2.1

.NET Standard 2.0

.NET 7.0

.NET 6.0

.NET 5.0

.NET Framework 4.7.1

Version Downloads Last updated
4.1.0-dev-00085 17 8/8/2024
4.1.0-dev-00082 16 8/3/2024
4.0.1-dev-00081 14 8/15/2024
4.0.1-dev-00079 16 7/15/2024
4.0.0 16 8/12/2024
4.0.0-dev-00071 16 8/16/2024
3.0.0 20 3/7/2024
3.0.0-dev-00063 20 3/7/2024
2.0.0 20 3/9/2024
2.0.0-dev-00060 21 3/7/2024
1.0.6-dev-00059 19 3/7/2024
1.0.5 19 3/9/2024
1.0.5-dev-00048 17 3/7/2024
1.0.4 21 3/9/2024
1.0.3 20 3/9/2024
1.0.3-dev-00036 19 3/7/2024
1.0.3-dev-00034 21 3/7/2024
1.0.3-dev-00033 20 3/7/2024
1.0.2 23 3/9/2024
1.0.2-dev-00024 22 3/7/2024
1.0.2-dev-00020 21 3/7/2024
1.0.1 21 3/9/2024
1.0.1-dev-00016 21 3/7/2024
1.0.1-dev-00014 22 3/7/2024
1.0.0 20 3/9/2024
1.0.0-dev-00010 23 3/7/2024
1.0.0-dev-00008 20 3/7/2024
1.0.0-dev-00006 22 3/7/2024
1.0.0-dev-00004 20 3/7/2024
1.0.0-dev-00002 20 3/7/2024
1.0.0-dev-00001 19 3/7/2024