Serilog.Formatting.Compact.Reader 4.1.0-dev-00082
Serilog.Formatting.Compact.Reader
This package reads (deserializes) JSON log files created by Serilog.Formatting.Compact back into Serilog LogEvent
s.
Example
Log events are written to a file using CompactJsonFormatter
:
await 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":"2024-10-12T04:46:58.0554314Z","@mt":"Hello, {@User}","User":{"Name":"nblumhardt","Id":101}}
{"@t":"2024-10-12T04:46:58.0684369Z","@mt":"Number {N:x8}","@r":["0000002a"],"N":42}
{"@t":"2024-10-12T04:46:58.0724384Z","@mt":"Tags are {Tags}","@l":"Warning","Tags":["test","orange"]}
{"@t":"2024-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:
await using var console = new LoggerConfiguration()
.WriteTo.Console()
.CreateLogger();
await using var clef = File.OpenText("log.clef"))
var reader = new LogEventReader(clef);
while (reader.TryRead(out var evt))
console.Write(evt);
Output from the logger:
Limitations
Events deserialized from JSON are for typical purposes just like the original log events. There are two main things to keep in mind:
- JSON doesn't carry all of the type information necessary to determine if, for example, a number is an
int
or afloat
. JSON.NET does a good job of deserializing anything that it encounters, but you can't rely on the types here being identical. - 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
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).
|
23 |
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).
|
26 |
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).
|
30 |
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).
|
1 |
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).
|
30 |
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).
|
4 |
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).
|
22 |
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).
|
27 |
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).
|
31 |
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.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).
|
1 |
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).
|
26 |
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).
|
24 |
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).
|
23 |
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).
|
25 |
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).
|
23 |
.NET Framework 4.6.2
- Newtonsoft.Json (>= 13.0.3)
- Serilog (>= 4.0.0)
.NET Framework 4.7.1
- Newtonsoft.Json (>= 13.0.3)
- Serilog (>= 4.0.0)
.NET 6.0
- Newtonsoft.Json (>= 13.0.3)
- Serilog (>= 4.0.0)
.NET 8.0
- Newtonsoft.Json (>= 13.0.3)
- Serilog (>= 4.0.0)
.NET Standard 2.0
- Newtonsoft.Json (>= 13.0.3)
- Serilog (>= 4.0.0)
Version | Downloads | Last updated |
---|---|---|
4.1.0-dev-00085 | 11 | 08/18/2024 |
4.1.0-dev-00082 | 20 | 07/22/2024 |
4.0.1-dev-00081 | 21 | 07/22/2024 |
4.0.1-dev-00079 | 28 | 07/22/2024 |
4.0.0 | 22 | 07/22/2024 |
4.0.0-dev-00071 | 27 | 07/22/2024 |
3.0.0 | 23 | 07/22/2024 |
3.0.0-dev-00063 | 20 | 07/22/2024 |
2.0.0 | 22 | 07/22/2024 |
2.0.0-dev-00060 | 15 | 07/22/2024 |
1.0.6-dev-00059 | 22 | 07/22/2024 |
1.0.5 | 22 | 07/22/2024 |
1.0.5-dev-00048 | 26 | 07/22/2024 |
1.0.4 | 24 | 07/22/2024 |
1.0.3 | 30 | 07/22/2024 |
1.0.3-dev-00036 | 20 | 07/22/2024 |
1.0.3-dev-00034 | 13 | 07/22/2024 |
1.0.3-dev-00033 | 19 | 07/22/2024 |
1.0.2 | 20 | 07/22/2024 |
1.0.2-dev-00024 | 37 | 07/22/2024 |
1.0.2-dev-00020 | 21 | 07/22/2024 |
1.0.1 | 26 | 07/22/2024 |
1.0.1-dev-00016 | 24 | 07/22/2024 |
1.0.1-dev-00014 | 25 | 07/22/2024 |
1.0.0 | 28 | 07/22/2024 |
1.0.0-dev-00010 | 33 | 07/22/2024 |
1.0.0-dev-00008 | 25 | 07/22/2024 |
1.0.0-dev-00006 | 24 | 07/22/2024 |
1.0.0-dev-00004 | 22 | 07/22/2024 |
1.0.0-dev-00002 | 17 | 07/22/2024 |
1.0.0-dev-00001 | 19 | 07/22/2024 |