AGC.ActionLogger 1.0.1

dotnet add package AGC.ActionLogger --version 1.0.1
                    
NuGet\Install-Package AGC.ActionLogger -Version 1.0.1
                    
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="AGC.ActionLogger" Version="1.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="AGC.ActionLogger" Version="1.0.1" />
                    
Directory.Packages.props
<PackageReference Include="AGC.ActionLogger" />
                    
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 AGC.ActionLogger --version 1.0.1
                    
#r "nuget: AGC.ActionLogger, 1.0.1"
                    
#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 AGC.ActionLogger@1.0.1
                    
#: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=AGC.ActionLogger&version=1.0.1
                    
Install as a Cake Addin
#tool nuget:?package=AGC.ActionLogger&version=1.0.1
                    
Install as a Cake Tool

Advanced Logger ๐Ÿ“‹

A powerful and extensible .NET logging library with support for:

  • โœ… File-based logging with size-based rotation
  • โœ… Environment-based log separation
  • โœ… Dependency Injection support (ICustomLogger)
  • โœ… Multi-sink logging (File, DB, Microsoft ILogger, Serilog)
  • โœ… Log cleanup policy
  • โœ… Structured & async logging
  • โœ… Custom log types (Info, Error, Success, Action, FileUpload)

๐Ÿ“ฆ Installation

Install via NuGet:

dotnet add package AGC.ActionLogger

Or via NuGet Package Manager:

Install-Package AGC.ActionLogger

๐Ÿ› ๏ธ Setup

Step 1: Register the logger in Startup.cs / Program.cs

using Agc.SwapTech.ActionLogger.Extensions;

builder.Services.AddAdvancedLogging(); // Registers File + DB + Microsoft logger sink

Optional: Enable Serilog or customize logger types:

builder.Services.AddAdvancedLogging(useSerilog: true);

๐Ÿš€ Usage

Inject ICustomLogger in any class/controller

public class HomeController : Controller
{
    private readonly ICustomLogger _logger;

    public HomeController(ICustomLogger logger)
    {
        _logger = logger;
    }

    public IActionResult Index()
    {
        _logger.LogInfo("Index page loaded");
        _logger.LogAction("User clicked dashboard");
        _logger.LogSuccess("Operation successful");
        _logger.LogFileUpload("User uploaded profile picture");
        _logger.LogError("Something went wrong");

        return View();
    }
}

โœ… Features

Feature Description
๐Ÿงพ File Logging Logs are written daily under /Logs/{EnvironmentName}/yyyy-MM-dd.log
๐Ÿ”„ Log Rotation Each log file rotates after 5MB
๐Ÿงผ Log Cleanup Automatically delete logs older than 7 days
๐Ÿง  Dependency Injection Use ICustomLogger anywhere
๐ŸŒ Environment-based Logs are stored separately per environment
๐Ÿ“ฆ Multi-output Logs can be written to file, DB, and Microsoft ILogger simultaneously
๐Ÿ” Structured Logging Support for structured JSON log entries
โณ Async Logging Queue-based async logging available
๐Ÿงญ Correlation ID Add custom request-level correlation ID logging (optional)

๐Ÿ—ƒ๏ธ Optional DB Logging

Add this table to your database:

CREATE TABLE Logs (
    Id INT IDENTITY PRIMARY KEY,
    Timestamp DATETIME,
    Level NVARCHAR(50),
    Message NVARCHAR(MAX)
);

Add this to appsettings.json:

"ConnectionStrings": {
  "DefaultConnection": "Server=.;Database=LoggingDb;Trusted_Connection=True;"
}

๐Ÿงช Advanced Usage

Log with manual level

_logger.Log("Custom audit message", LogLevel.Warning);

Cleanup logs manually

_logger.CleanupOldLogs(daysToKeep: 10);

Structured logging (JSON-based)

Automatically formatted when structured mode is enabled

{
  "Timestamp": "2025-06-14T10:00:00Z",
  "Level": "Information",
  "Message": "File uploaded",
  "Environment": "Production",
  "MachineName": "APP-SERVER-01"
}

๐Ÿค Contributing

Feel free to submit pull requests, log issues, or request features!


๐Ÿ“œ License

MIT License


๐Ÿ“ง Support

Need help or want to suggest a feature? Create an issue or contact umesh.chavan90@outlook.com.

Product 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. 
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
1.0.1 169 6/14/2025
1.0.0 185 5/31/2025 1.0.0 is deprecated because it is no longer maintained.