Author : MD TAREQ HASSAN | Updated : 2020/10/26
Serilog
Serilog is a diagnostic logging library for .NET applications. Serilog’s support for structured logging shines when instrumenting complex, distributed, and asynchronous applications and systems
- Serilog is built from the ground up to record structured event data
- Serilog thinks in terms of log events, not log messages. An event is made up of:
- A timestamp recording when the event happened
- A level describing when the event should be captured
- A message documenting what the event represents
- Named properties describing the event
- Possibly an Exception object
- Log output sample:
- console:
11:33:01 [INF] Hello, Serilog!
- JSON :
{"@t":"2017-11-20T11:33:01.22138","@m":"Hello, Serilog!"}
- console:
- Behind the scenes, logging statements in your application create LogEvent objects, while the sinks attached to the pipeline figure out how to record them.
- On LogEvents, properties added through enrichment appear the same as properties originating from the message template
Overview of Serilog
- ILogger interface
- LoggerConfiguration
- Log
- Static class (an optional static entry point)
Log.Logger
: static propertypublic static ILogger Logger { get; set; }
Log.<StaticMethod>()
: to logLog.Logger = new LoggerConfiguration().....CreateLogger();
- https://github.com/serilog/serilog/blob/dev/src/Serilog/Log.cs