https://github.com/ysden123/dotnetlogging
Playing with some logging packets for projects on C#.
https://github.com/ysden123/dotnetlogging
csharp dotnet logging playing
Last synced: about 2 months ago
JSON representation
Playing with some logging packets for projects on C#.
- Host: GitHub
- URL: https://github.com/ysden123/dotnetlogging
- Owner: ysden123
- License: mit
- Created: 2025-06-06T09:38:36.000Z (about 1 year ago)
- Default Branch: master
- Last Pushed: 2025-06-07T10:04:53.000Z (about 1 year ago)
- Last Synced: 2025-06-07T11:18:54.277Z (about 1 year ago)
- Topics: csharp, dotnet, logging, playing
- Language: C#
- Homepage:
- Size: 4.88 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# DotNetLogging
Playing with some logging packets for projects on C#.
## PNLog
Examples of using the NLog package.
## PSerilog
Examples of using the Serilog package.
## PSerilogWOInit
Examples of using the Serilog package without the logger initialization.
The SilentLogger will be used and no output will be performed.
This refers to situations where you call Log.Information(),
Log.Warning(), etc., without first setting Log.Logger = new
LoggerConfiguration().CreateLogger();
Serilog is designed to be robust. If Log.Logger hasn’t been explicitly
configured, it falls back to a default "`no-op`" logger.
The default "`no-op`" logger that Serilog uses when it hasn’t been
initialized is indeed called SilentLogger.
As its name implies, SilentLogger does not write any logs to any sink
(console, file, etc.). It effectively swallows all log events.
Why this behavior exists and why it’s useful:
* Robustness in Libraries: If you’re building a library that uses Serilog
for its internal logging, you don’t want to force the consuming
application to configure Serilog. If they don’t configure it, your
library’s logging will simply be silent, without causing errors or
unexpected output.
* Early Application Startup: Sometimes, you might have code that runs very
early in your application’s lifecycle, even before your main Serilog
configuration is set up. In such cases, if you attempt to log, Serilog
will gracefully use the SilentLogger until the full configuration is in
place.
* Testing: In unit tests, you often don’t want your tests to produce
actual log output. If your code uses Log.Information() directly and you
don’t initialize Serilog in your tests, it will use SilentLogger,
keeping your test output clean.