MandalaConsulting.Logging
0.0.5
See the version list below for details.
dotnet add package MandalaConsulting.Logging --version 0.0.5
NuGet\Install-Package MandalaConsulting.Logging -Version 0.0.5
<PackageReference Include="MandalaConsulting.Logging" Version="0.0.5" />
<PackageVersion Include="MandalaConsulting.Logging" Version="0.0.5" />
<PackageReference Include="MandalaConsulting.Logging" />
paket add MandalaConsulting.Logging --version 0.0.5
#r "nuget: MandalaConsulting.Logging, 0.0.5"
#:package MandalaConsulting.Logging@0.0.5
#addin nuget:?package=MandalaConsulting.Logging&version=0.0.5
#tool nuget:?package=MandalaConsulting.Logging&version=0.0.5
MandalaConsulting.Logging
Overview
The MandalaConsulting.Logging library provides a robust and flexible logging framework for .NET applications. It features a standardized LogMessage
class that allows developers to create and manage detailed log entries efficiently. With support for various log message types and event-driven logging, this library is designed to streamline application monitoring and debugging.
Features
- Standardized Log Object: Encapsulates log details like message type, timestamp, and source.
- Event-Driven Logging: Triggers events when new log messages are added.
- Predefined Log Levels: Includes types such as
Informational
,Warning
,Error
,Critical
,Success
, and more. - Static Factory Methods: Simplifies log creation with utility methods.
- Source Tracking: Automatically captures the source of the log within the application.
Installation
Include the library in your .NET project and reference the MandalaConsulting.Logging
namespace.
Usage
Import the Namespace
using MandalaConsulting.Logging;
LogMessage Class
The LogMessage
class serves as the core object for capturing log details. It supports multiple constructors and static factory methods for creating various types of log entries.
Properties
id
: Unique identifier for the log message.localOperationName
: Captures the name of the method generating the log.message
: The content of the log entry.messageSource
: A customizable identifier for the program or module generating the log.messageType
: Categorizes the log (e.g.,Informational
,Error
).timeStamp
: Timestamp when the log was created.
Creating Logs
Using Constructors
LogMessage log = new LogMessage(MessageType.Informational, "This is an informational message.");
Using Static Methods
LogMessage infoLog = LogMessage.Informational("This is an informational message.");
LogMessage errorLog = LogMessage.Error("An error occurred while processing the request.");
Example with IDs
LogMessage successLog = LogMessage.Success(1, "Operation completed successfully.");
LogMessage warningLog = LogMessage.Warning(2, "This is a warning message.");
Events
LogAdded Event
Triggered whenever a new log message is created.
LogMessage.LogAdded += (sender, args) =>
{
Console.WriteLine($"Log Added: {args.log.message}");
};
Log Types
The LogMessage
class supports several predefined log types:
Type | Description |
---|---|
Celebrate |
Logs celebrating a milestone or achievement. |
Critical |
Logs critical issues that require immediate attention. |
Error |
Logs errors encountered during execution. |
Informational |
Logs general information about operations. |
Message |
Logs a general-purpose message. |
Success |
Logs successful operations or results. |
Warning |
Logs warnings that may require attention. |
Example Usage
Basic Logging
LogMessage.LogAdded += (sender, args) =>
{
Console.WriteLine($"Log: {args.log.timeStamp} - {args.log.messageType} - {args.log.message}");
};
LogMessage log = LogMessage.Error("A critical error occurred.");
Customizing the Message Source
LogMessage.MessageSourceSetter = "MyApplication";
LogMessage log = LogMessage.Success("Application started successfully.");
Requirements
- .NET Framework or .NET Core
License
This project is copyrighted © 2023 Mandala Consulting, LLC.
All Rights Reserved.
Author
Created by Alexander Fields
For inquiries, please contact Mandala Consulting.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | 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 was computed. 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. |
-
net8.0
- No dependencies.
NuGet packages (2)
Showing the top 2 NuGet packages that depend on MandalaConsulting.Logging:
Package | Downloads |
---|---|
MandalaConsulting.APIMiddlewares
Middlewares for APIs - MandalaConsulting.APIMiddlewares |
|
MandalaConsulting.Repository.Mongo
Repository for Generic Mongo Usage - MandalaConsulting.Repository.Mongo |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last Updated |
---|---|---|
0.0.8 | 137 | 7/15/2025 |
0.0.7 | 331 | 7/5/2025 |
0.0.6 | 270 | 6/26/2025 |
0.0.5 | 422 | 6/8/2025 |
0.0.4 | 195 | 6/8/2025 |
0.0.4-develop.8 | 170 | 6/8/2025 |
0.0.3 | 1,176 | 10/15/2024 |
0.0.3-develop.7 | 164 | 6/8/2025 |
0.0.2 | 121 | 10/15/2024 |
0.0.1 | 205 | 10/12/2024 |