Witkenma.NugetPackage.Common 2.0.12

dotnet add package Witkenma.NugetPackage.Common --version 2.0.12
                    
NuGet\Install-Package Witkenma.NugetPackage.Common -Version 2.0.12
                    
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="Witkenma.NugetPackage.Common" Version="2.0.12" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Witkenma.NugetPackage.Common" Version="2.0.12" />
                    
Directory.Packages.props
<PackageReference Include="Witkenma.NugetPackage.Common" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Witkenma.NugetPackage.Common --version 2.0.12
                    
#r "nuget: Witkenma.NugetPackage.Common, 2.0.12"
                    
#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.
#:package Witkenma.NugetPackage.Common@2.0.12
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Witkenma.NugetPackage.Common&version=2.0.12
                    
Install as a Cake Addin
#tool nuget:?package=Witkenma.NugetPackage.Common&version=2.0.12
                    
Install as a Cake Tool

1. What is this project for

Creating this project for common nuget package manager management.

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT

Serilog is a popular logging library for .NET applications. It provides a flexible and structured way to log events, errors, and other information in your application. Serilog is known for its extensibility, allowing developers to customize the logging configuration based on their specific needs.

  1. Create a new console application or any other type of project where you want to use Srlogs.
  2. Install the Witkenma.NugetPackage.Common NuGet package. You can do this by referencing the published NuGet package or by adding a project reference, depending on your setup.

Use Srlogs in Your Application

using Microsoft.Extensions.Configuration; using System;

class Program { static void Main() { // Initialize Srlogs during application startup var srlogs = Srlogs.Instance; // Log messages using Srlogs // srlogs.LogVerbose("This is a verbose message."); srlogs.LogDebug("This is a debug message."); srlogs.LogInformation("This is an information message."); srlogs.LogWarning("This is a warning message."); srlogs.LogError("This is an error message.");

    // Reload configuration (if needed)
    var updatedConfiguration = new ConfigurationBuilder()
        .AddJsonFile("appsettings.json")
        .Build();

    srlogs.ReloadConfiguration(updatedConfiguration);

    Console.ReadLine();
}

}

appsettings.json can be modified for Srlogs

User Claim class

Added a claim class for retrieving claim information of the logged-in user. Example: UserClaims userClaims = new UserClaims(HttpContext.User.Claims);

// Now you can use userClaims to access user-related information throughout your application string userName = userClaims.GetName(); string jwtId = userClaims.GetJwtId();

Common Messages class

For obtaining different types of common messages for the application.

StringExtensions

A static class containing extension methods for string manipulation.

Product Compatible and additional computed target framework versions.
.NET 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 was computed.  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. 
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
2.0.12 227 3/28/2025
2.0.11 235 3/22/2025
2.0.10 400 3/20/2025 2.0.10 is deprecated because it is no longer maintained and has critical bugs.
2.0.9 183 2/13/2025
2.0.8 162 2/2/2025
2.0.7 233 3/17/2024
2.0.6 210 2/20/2024
2.0.5 176 2/18/2024
2.0.4 170 2/17/2024
2.0.3 228 2/7/2024
2.0.2 166 2/5/2024
2.0.1 174 1/28/2024
2.0.0 170 1/28/2024
1.0.2 395 3/4/2023 1.0.2 is deprecated because it is no longer maintained.
1.0.1 377 3/4/2023 1.0.1 is deprecated because it is no longer maintained.
1.0.0 388 3/4/2023 1.0.0 is deprecated because it is no longer maintained.

Release Notes for ContainsContact Class on .net 9.0
Version: 2.0.12
Date: March 28, 2025


New Features:
Enhanced Logging Capabilities:

Fatal Error Logging:

Added LogFatal method to log critical or fatal errors. This can be used for serious issues that require immediate attention.

LogFatal now accepts both a simple message and an exception to log critical failures in the system.

Trace Logging:

Added LogTrace to capture detailed trace-level logging for debugging purposes, ideal for monitoring fine-grained application behavior.

Metric Logging:

Added LogMetric for tracking performance metrics (e.g., elapsed time, execution time). This is useful for performance monitoring in production.

Structured Data Logging:

Added LogStructuredData to log complex objects in a structured manner, ensuring all relevant data is captured in logs.

Structured logging enables better analytics and visualization of logs.

Custom Event Logging:

Introduced LogEvent for logging custom business events with structured data, making it easy to track application-specific actions and activities.

Session Info Logging:

Added LogSessionInfo to log information related to user sessions, such as session IDs and durations. This helps with tracking user interactions and session management.

User-Specific Error Logging:

Added LogErrorWithUser to log errors along with user-specific details. This is useful for tracking errors tied to specific users or user sessions.

Environment Information Logging:

Added LogEnvironmentInfo to capture and log environment-related details, such as machine name, application version, and environment type (e.g., development, production).

Improvements:
Exception Logging Enhancements:

The LogError method now accepts an additional parameter: an exception object, enabling detailed logging of exceptions with stack traces.

Better error context by adding exception details for easier troubleshooting.

Bug Fixes:
Minor Fixes:

Fixed minor internal issues related to logger initialization and configuration loading.

Enhanced thread-safety mechanisms for ensuring correct singleton behavior in Srlogs class.

Usage Example:
Here is a quick overview of how you can use the new methods:

csharp
Copy
try
{
// Simulate an error by dividing by zero
int result = 10 / 0;
}
catch (Exception ex)
{
// Log the error with exception details
Srlogs.Instance.LogError("An error occurred during operation", ex);

// Log the fatal error
Srlogs.Instance.LogFatal("Critical error: System failure", ex);

// Log user-specific error
Srlogs.Instance.LogErrorWithUser("user123", "Error while processing user request", ex);

// Log the environment details
Srlogs.Instance.LogEnvironmentInfo();

// Log performance metrics (e.g., elapsed time)
Srlogs.Instance.LogMetric("RequestProcessingTime", 250);
}