DevInstance.LogScope.Extensions.MicrosoftLogger
0.9.1
See the version list below for details.
dotnet add package DevInstance.LogScope.Extensions.MicrosoftLogger --version 0.9.1
NuGet\Install-Package DevInstance.LogScope.Extensions.MicrosoftLogger -Version 0.9.1
<PackageReference Include="DevInstance.LogScope.Extensions.MicrosoftLogger" Version="0.9.1" />
paket add DevInstance.LogScope.Extensions.MicrosoftLogger --version 0.9.1
#r "nuget: DevInstance.LogScope.Extensions.MicrosoftLogger, 0.9.1"
// Install DevInstance.LogScope.Extensions.MicrosoftLogger as a Cake Addin
#addin nuget:?package=DevInstance.LogScope.Extensions.MicrosoftLogger&version=0.9.1
// Install DevInstance.LogScope.Extensions.MicrosoftLogger as a Cake Tool
#tool nuget:?package=DevInstance.LogScope.Extensions.MicrosoftLogger&version=0.9.1
LogScope
.NET Standard 2.0: Logging, tracing and profiling
LogScope implements simple logging framework for tracing, profiling and logging methods and critical parts of the code. It can be integrated with popular logging library (such as Log4Net, NLog, etc). The whole idea is around using a “scope”. Scope can be method or a specific part of it. The implementation is based on IDisposable where calling Dispose ends the scope. The following example demonstrate this approach:
{
using (var methodScope = classScope.DebugScope())
{
methodScope.D("Inside of method Foo scope");
Thread.Sleep(200);
}
}
Result:
--> begin of Foo
Foo: Inside of method Foo scope
<-- end of Foo, time:3 msec
It can be useful for the apps to trace the performance or async code calls.
class TestClass
{
IScopeLog classScope;
public TestClass(IScopeManager manager)
{
classScope = manager.CreateLogger(this);
}
public void MethodA()
{
using (var methodScope = classScope.DebugScope())
{
methodScope.D("Wait for 200 msec");
Thread.Sleep(200);
methodScope.D("Done.");
using (var aScope = methodScope.DebugScope("a-scope"))
{
aScope.D("Inside of a scope");
}
MethodB();
}
}
private void MethodB()
{
using (var methodScope = classScope.DebugScope())
{
methodScope.D("Inside of method B scope");
Thread.Sleep(200);
}
}
}
Result:
21-01-29 23:07:24--> begin of TestClass:MethodA
21-01-29 23:07:24 TestClass:MethodA:Wait for 200 msec
21-01-29 23:07:25 TestClass:MethodA:Done.
21-01-29 23:07:25--> begin of TestClass:MethodA:a-scope
21-01-29 23:07:25 TestClass:MethodA:a-scope:Inside of a scope
21-01-29 23:07:25<-- end of TestClass:MethodA:a-scope, time:2.1252 msec
21-01-29 23:07:25--> begin of TestClass:MethodB
21-01-29 23:07:25 TestClass:MethodB:Inside of method B scope
21-01-29 23:07:25<-- end of TestClass:MethodB, time:212.748 msec
21-01-29 23:07:25<-- end of TestClass:MethodA, time:480.5525 msec
See more https://devinstance.net/blog/dotnet-standard-logging-and-profiling
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 is compatible. net5.0-windows was computed. net6.0 was computed. 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 was computed. 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. |
-
net5.0
- DevInstance.LogScope (>= 1.2.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 5.0.0)
- Microsoft.Extensions.Logging (>= 5.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Support of LogScope 1.2.0