Skip to content

netmodules/NetTools.Logging

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NetTools.Logging

NetTools.Logging is a lightweight and standardized .NET logging library that enables multiple logging implementations across applications. By leveraging a centralized Loggers class, developers can register and invoke logging across multiple loggers with ease.

This library is designed to provide extensibility while maintaining simplicity, allowing users to integrate their own logging mechanism by implementing the ILogger interface.


Features

  • Multi-Logger Support: Register multiple loggers to handle different logging methods.
  • Easy Integration: Implement ILogger to create custom loggers that follow a strict design pattern.
  • Flexible Usage: Invoke logging methods across all registered loggers using the central Loggers class.

Getting Started

Installation

To use NetTools.Logging, add the library via NuGet Package Manager:

Install-Package NetTools.Logging

Quick Examples

Adding a Custom Logger

This library itself doesn't do any logging, and is designed to strictly enforce interface logging across multiple loggers. First, you need to create a logger implementing ILogger:

using System;
using NetTools.Logging;

// This is an incredibly simple implementation of the ILogger interface.
public class ConsoleLogger : ILogger
{
    public void Log(params object[] args) => Console.WriteLine($"{string.Join(" ", args)}");
}

Then, add the custom logger to NetTools.Logging.Log loggers:

Log.AddLogger(new ConsoleLogger());

Logging Messages

Once the logger has been registered, you can use the Log class to log messages, this will invoke logging on all added loggers:

Loggers.Log("ERROR", "An error occurred in the system.");
Loggers.Log("User logged in at", DateTime.UtcNow);
Loggers.Log("Service started successfully.");
Loggers.Log("Debugging mode enabled.");

This simple library is used by NetModules.Logging.LocalLogging, a simple, commercially battle tested, NetModules module for logging module messages to local files.

Contributing

We welcome contributions! To get involved:

  1. Fork NetTools.Logging, make improvements, and submit a pull request.
  2. Code will be reviewed upon submission.
  3. Join discussions via the issues board.

License

NetModules is licensed under the MIT License, allowing unrestricted use, modification, and distribution. If you use NetTools.Logging in your own project, we’d love to hear about your experience, and possibly feature you on our website!

Full documentation coming soon!

NetModules Foundation

About

A lightweight .NET Standard 2.1 logging library that enables multiple logging implementations across applications

Resources

Stars

Watchers

Forks

Contributors

Languages