OutWit.Common.Logging
1.2.2
See the version list below for details.
dotnet add package OutWit.Common.Logging --version 1.2.2
NuGet\Install-Package OutWit.Common.Logging -Version 1.2.2
<PackageReference Include="OutWit.Common.Logging" Version="1.2.2" />
<PackageVersion Include="OutWit.Common.Logging" Version="1.2.2" />
<PackageReference Include="OutWit.Common.Logging" />
paket add OutWit.Common.Logging --version 1.2.2
#r "nuget: OutWit.Common.Logging, 1.2.2"
#:package OutWit.Common.Logging@1.2.2
#addin nuget:?package=OutWit.Common.Logging&version=1.2.2
#tool nuget:?package=OutWit.Common.Logging&version=1.2.2
Install
Install-Package OutWit.Common.Logging
or
> dotnet add package OutWit.Common.Logging
Streamlining Logging with the Log Aspect
Maintaining logs is critical for debugging and supporting complex applications. Manually adding logging calls everywhere can be tedious and error-prone. The OutWit.Common.Logging package simplifies this process with three powerful aspects: Log, NoLog, and Measure. The source code is available here.
Setting Up the Logger
Before using the logging aspects, initialize the logger. The current implementation is based on Serilog:
Log.Logger = new LoggerConfiguration()
.MinimumLevel.Is(LogEventLevel.Information)
.Enrich.WithExceptionDetails()
.WriteTo.File(@"D:\Log\Log.txt",
rollingInterval: RollingInterval.Day,
rollOnFileSizeLimit: true,
fileSizeLimitBytes: 524288)
.CreateLogger();
The Log Aspect
The Log aspect can be applied to individual methods:
public class Model
{
[Log]
public void DoSomething1()
{
}
public void DoSomething2()
{
}
}
Or to an entire class:
[Log]
public class Model
{
public void DoSomething1()
{
}
public void DoSomething2()
{
}
}
When applied to a class, it automatically applies to all methods within the class.
What Does the Log Aspect Do?
- Exception Handling: Wraps method execution in a try-catch block and logs exceptions with their details.
- Method Execution Logging: Logs method calls (excluding property getters/setters) if the logger’s MinimumLevel is Information or lower.
- Detailed Property Access Logging: If the logger’s MinimumLevel is Verbose, it also logs property access.
This flexibility allows you to control log verbosity by adjusting the logger's configuration.
The NoLog Aspect
If the Log aspect is applied to a class, but you want to exclude specific methods from logging, you can use the NoLog aspect:
[Log]
public class Model
{
public void DoSomething1()
{
}
[NoLog]
public void DoSomething2()
{
}
}
The Measure Aspect
To measure the execution time of a method, apply the Measure aspect. This will log the duration in milliseconds:
public class Model
{
public void DoSomething1()
{
}
[Measure]
public void DoSomething2()
{
}
}
When DoSomething2 is called, the log will include the method’s execution time.
Key Benefits
- Automates logging for methods and properties.
- Simplifies exception handling by centralizing logging.
- Provides flexible control over log verbosity.
- Enables easy performance measurement.
For more details, check out the article.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 is compatible. 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 is compatible. 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 is compatible. 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. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.0)
- OutWit.Common.Aspects (>= 1.3.2)
- Serilog (>= 4.3.0)
- Serilog.Exceptions (>= 8.4.0)
- Serilog.Extensions.Logging (>= 9.0.2)
- Serilog.Sinks.Debug (>= 3.0.0)
- Serilog.Sinks.File (>= 7.0.0)
- Serilog.Sinks.TestCorrelator (>= 4.0.0)
-
net10.0
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.0)
- OutWit.Common.Aspects (>= 1.3.2)
- Serilog (>= 4.3.0)
- Serilog.Exceptions (>= 8.4.0)
- Serilog.Extensions.Logging (>= 9.0.2)
- Serilog.Sinks.Debug (>= 3.0.0)
- Serilog.Sinks.File (>= 7.0.0)
- Serilog.Sinks.TestCorrelator (>= 4.0.0)
-
net6.0
- Microsoft.Extensions.Logging.Abstractions (>= 8.0.3)
- OutWit.Common.Aspects (>= 1.3.2)
- Serilog (>= 4.3.0)
- Serilog.Exceptions (>= 8.4.0)
- Serilog.Extensions.Logging (>= 8.0.0)
- Serilog.Sinks.Debug (>= 3.0.0)
- Serilog.Sinks.File (>= 7.0.0)
- Serilog.Sinks.TestCorrelator (>= 4.0.0)
-
net7.0
- Microsoft.Extensions.Logging.Abstractions (>= 8.0.3)
- OutWit.Common.Aspects (>= 1.3.2)
- Serilog (>= 4.3.0)
- Serilog.Exceptions (>= 8.4.0)
- Serilog.Extensions.Logging (>= 8.0.0)
- Serilog.Sinks.Debug (>= 3.0.0)
- Serilog.Sinks.File (>= 7.0.0)
- Serilog.Sinks.TestCorrelator (>= 4.0.0)
-
net8.0
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.8)
- OutWit.Common.Aspects (>= 1.3.2)
- Serilog (>= 4.3.0)
- Serilog.Exceptions (>= 8.4.0)
- Serilog.Extensions.Logging (>= 9.0.2)
- Serilog.Sinks.Debug (>= 3.0.0)
- Serilog.Sinks.File (>= 7.0.0)
- Serilog.Sinks.TestCorrelator (>= 4.0.0)
-
net9.0
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.8)
- OutWit.Common.Aspects (>= 1.3.2)
- Serilog (>= 4.3.0)
- Serilog.Exceptions (>= 8.4.0)
- Serilog.Extensions.Logging (>= 9.0.2)
- Serilog.Sinks.Debug (>= 3.0.0)
- Serilog.Sinks.File (>= 7.0.0)
- Serilog.Sinks.TestCorrelator (>= 4.0.0)
NuGet packages (6)
Showing the top 5 NuGet packages that depend on OutWit.Common.Logging:
| Package | Downloads |
|---|---|
|
OutWit.Common.MVVM
Cross-platform base components for the MVVM pattern. Includes ViewModelBase, RelayCommand, DelegateCommand, SortedCollection, and Table data models. Platform-specific implementations are available in OutWit.Common.MVVM.WPF and OutWit.Common.MVVM.Avalonia packages. |
|
|
OutWit.Common.MVVM.Avalonia
Avalonia-specific helpers and components for the MVVM pattern. Includes AvaloniaDispatcher, BindingUtils, visual tree traversal utilities, and automatic StyledProperty/DirectProperty generation via source generator and AspectInjector. This is part of the OutWit.Common.MVVM family of libraries. |
|
|
OutWit.Common.MVVM.Blazor
Blazor-specific helpers and components for the MVVM pattern. Includes ViewModelBase, BlazorDispatcher, and utilities for building Blazor applications with MVVM pattern. This is part of the OutWit.Common.MVVM family of libraries. |
|
|
OutWit.Common.MVVM.WPF
WPF-specific helpers and components for the MVVM pattern. Includes Command, BindingUtils, DataTemplateUtils, visual tree traversal utilities, and automatic DependencyProperty generation via source generator and AspectInjector. This is part of the OutWit.Common.MVVM family of libraries. |
|
|
OutWit.Engine.Interfaces
Core interface definitions and contracts for the WitEngine distributed computing system. Provides interfaces for activities, variables, jobs, processing, benchmarking, and plugin development. |
GitHub repositories
This package is not used by any popular GitHub repositories.