LoggingAspect 1.0.1
dotnet add package LoggingAspect --version 1.0.1
NuGet\Install-Package LoggingAspect -Version 1.0.1
<PackageReference Include="LoggingAspect" Version="1.0.1" />
paket add LoggingAspect --version 1.0.1
#r "nuget: LoggingAspect, 1.0.1"
// Install LoggingAspect as a Cake Addin #addin nuget:?package=LoggingAspect&version=1.0.1 // Install LoggingAspect as a Cake Tool #tool nuget:?package=LoggingAspect&version=1.0.1
Assembly to allow logging via Attributes
Logging for a class is enabled by decorating it with the [Loggable] attribute and deriving from ContextBoundObject.
Another option is to derive from LoggableObject.
The [Log] attribute will enable logging with de Default logger. The DefaultMessageLogger and DefaultExceptionLogger in Loggers can be replaced with custom implementations.
The [LogWith(Type)] allowes to specify a logger type that should be used for logging the method. A Custom Logger specified by this attribute must have a parameterless constructor.
Both Attributes can be used as class / method attributes. When used as class attributes loggers will be called for every external call to the object. It is possible to combine both variants.
If the logger implements MethodLogger method entry and leaving will be logged.
If the logger implements ExceptionLogger than all exception will be logged.
It is possible to implement both interfaces and enable standard and exception logging with just 1 attribute.
It is possible to specify multiple loggers
In order to create complex Loggers (with parameters / Properties to be provided) you can provide an own ObjectResolver (Loggers.LoggerResolver). e.g. for using a Dependency-Injection container or service locator
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET Framework | net40 is compatible. net403 was computed. net45 was computed. net451 was computed. net452 was computed. net46 was computed. net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
This package has no dependencies.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.0.1 | 132 | 1/19/2015 |
LogAttributes as ClassAttributes enables the logging behind an interface without exposing the attributes in the interface. However the loggers themselves must distinguish between the methods themselves.
LogWith attribute now supports multiple Loggers e.g. [LogWith(typeof(logger1), typeof(logger2) ...)]
Open issue:
Log/LogWith attributes have to be specified on the implemented interface if calls to the object are made through this interface. I am trying to resolve this but i am not sure if it is possible to only work with the attributes in the implementation