VtlSoftware.Aspects.Logging 2024.0.8

Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet add package VtlSoftware.Aspects.Logging --version 2024.0.8                
NuGet\Install-Package VtlSoftware.Aspects.Logging -Version 2024.0.8                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="VtlSoftware.Aspects.Logging" Version="2024.0.8" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add VtlSoftware.Aspects.Logging --version 2024.0.8                
#r "nuget: VtlSoftware.Aspects.Logging, 2024.0.8"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install VtlSoftware.Aspects.Logging as a Cake Addin
#addin nuget:?package=VtlSoftware.Aspects.Logging&version=2024.0.8

// Install VtlSoftware.Aspects.Logging as a Cake Tool
#tool nuget:?package=VtlSoftware.Aspects.Logging&version=2024.0.8                

VtlSoftware.Aspects.Logging

This packakage is a collection of aspects created with Metalama that will allow you to easily add logging to a project or collection of projects in a solution.

It should be possible to use it with whichever Logging Framework is your framework of choice with the caveat that that framework support the ILogger interface provided by Microsoft.Extensions.Logging which, in reality, is the vast majority of them.

The package is open source and free* to use.

  • Subject to meeting the requirements placed by PostSharp Metalama on their Free License.

Using VtlSoftware.Aspects.Logging

After adding the package to your project you will need to configure a logging framework. Examples of how this can be done can be found in the package's help file which is available online. There are also numerous examples of how this can be done to be found online.

Once that has been done then using it is as simple as adding an aspect (which is essentially adding an attribute) to those properties or methods that you want to be logged.

The library has been designed to provide both templated logging (log entry, exit and exceptions) and custom logging with your own log messages.

By taking this approach it is hoped that most peoples' needs will be covered.

Provided Aspects

[Log]

Adds logging to a method. Entry and exit is logged along with details of any parameters that were passed into it. If applicable the method's return value is also logged. In addition this aspect can log properties.

[LogAndTime]

Exactly the same as the [Log] aspect with the exception that the total duration that the method took to execute is also logged. In Addition this aspect can log properties but will not time the interaction with the property.

[InjectBasicLogging]

An aspect designed to make it easier for developers to add their own custom logging without having to use the provided aspects.

[InjectControlledLogging]

An aspect designed to make it easier for developers to add their own custom logging without having to use the provided aspects.

Provided Attributes

[Redact]

This attribute will prevent sensitive parameters, or results, from being logged. To be more precise rather that an actual value being recorded the word 'redacted' is substituted. Typical usage is as shown below.


//when redacting parameters do the following;

public bool ConfirmLogin(string userName, [Redact] string password)
{
	//Do stuff here.
}


// To redact a return then you need to apply the [Redact] attribute in the following way;

[Log]
[return: Redact]
public string GetMyPassword()
{
      return "MySuperSafePassword";
}


[NoLog]

When applied to a Class, Method or Property no logging of that entity will occur.

Fabric Extensions

A number of extion methods to provide Fabrics that will automate the process of adding logging aspects to your code base are also provided. You can find more details on how to use those in the help file.

Current provided extensions are.

AddBasicLoggingToAllClasses

Applies the [InjectBasicLogging] aspect to all eligible classes

AddControlledLoggingToAllClasses

Applies the [InjectControlledLogging] aspect to all eligible classes

LogAllMethods

Applies the [Log] aspect to all eligible methods.

LogAndTimeAllMethods

Applies the [LogAndTime] aspect to all eligible methods.

LogAllPublicMethods

Applies the [Log] aspect to all public methods.

LogAndTimeAllPublicMethods

Applies the [LogAndTime] aspect to all public methods.

LogAllPublicAndPrivateMethods

Applies the [Log] aspect to all public and Private Methods.

LogAndTimeAllPublicAndPrivateMethods

Applies the [LogAndTime] aspect to all public and Private Methods.

LogEverything

Applies the [Log] aspect to all methods and the [Log] aspect to all properties.

TimeEveryMethodAndLogEveryProperty

Applies the [LogAndTime] aspect to all methods and the [LogAndTime] aspect to all properties.

Help and Support

A comprehensive help file can be found here. It goes into considerably more detail than is possible within the confines of a readme file. It also offers some advice on using Metalama to create your own aspects.

Please ask questions or report any issues on the github repo as it will generally be picked up quiker that way.

Product Compatible and additional computed target framework versions.
.NET 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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2024.0.11 160 3/22/2024
2024.0.10 104 3/22/2024
2024.0.9.1 112 3/18/2024
2024.0.9 106 3/1/2024
2024.0.8 112 2/26/2024
2024.0.7 116 2/15/2024
2024.0.6 111 1/18/2024
2023.4.8 102 1/18/2024
2023.4.7 103 1/18/2024
2023.4.6 160 11/9/2023
2023.3.8.1 147 10/25/2023
2023.3.8 131 10/19/2023

Release Matches Metalama 2024.0.8
 It also updates other packaage dependencies to provide support for .Net 8.0