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" />
<PackageReference Include="AGC.ActionLogger" />
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
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#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
#tool nuget:?package=AGC.ActionLogger&version=1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
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 | 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0
- Microsoft.Data.SqlClient (>= 6.0.2)
- Microsoft.Extensions.Hosting.Abstractions (>= 9.0.6)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.