NaNTech.MongoDB.ULog
1.1.0.4
See the version list below for details.
dotnet add package NaNTech.MongoDB.ULog --version 1.1.0.4
NuGet\Install-Package NaNTech.MongoDB.ULog -Version 1.1.0.4
<PackageReference Include="NaNTech.MongoDB.ULog" Version="1.1.0.4" />
paket add NaNTech.MongoDB.ULog --version 1.1.0.4
#r "nuget: NaNTech.MongoDB.ULog, 1.1.0.4"
// Install NaNTech.MongoDB.ULog as a Cake Addin #addin nuget:?package=NaNTech.MongoDB.ULog&version=1.1.0.4 // Install NaNTech.MongoDB.ULog as a Cake Tool #tool nuget:?package=NaNTech.MongoDB.ULog&version=1.1.0.4
ULog Integration
ULog is a library that uses MongoDb to store both HTTP and manual logs in your database. It's straightforward to use and integrate into your .NET project.
Installation
To integrate ULog into your .NET project, add the following line:
builder.Services.AddULogger(connectionString, options, queueCount);
Configuration
The options
object is of type ULogOptions
and takes the following default values:
public class ULogOptions
{
public string[] Claims { get; set; } = [ClaimTypes.Name];
public string ManualLogDbName { get; set; } = "logs";
public string HttpLogDbName { get; set; } = "httplogs";
public string ManualCollectionName { get; set; } = DateTime.Now.Date.ToString("yyyy-MM-dd");
public string HttpCollectionName { get; set; } = DateTime.Now.Date.ToString("yyyy-MM-dd");
}
The queueCount
parameter determines how many logs are queued, with a default value of 2000
.
It's recommended to specify the Claims
section yourself when add IoT.
For Http logging you should add :
[ULog]
attribute above action or controller.
UI Usage
To use the ULog UI, add the following line to your setup:
app.UseULoggerUI();
Navigate to localhost/ULog/index.html
to view your logs in a table format.
Example
Here's a simple example to get you started:
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddULogger("your-connection-string", new ULogOptions
{
Claims = "your-claims-for-user",
ManualLogDbName = "your-logs-db",
HttpLogDbName = "your-httplogs-db",
ManualCollectionName = "your-manual-collection",
HttpCollectionName = "your-http-collection"
}, 2000);
var app = builder.Build();
app.UseULoggerUI();
app.Run();
Conclusion
ULog provides a simple and efficient way to manage logs in your .NET application using MongoDb. By following the above steps, you can quickly set up and start using ULog in your projects.
Thank you for using ULog! If you encounter any issues or have questions, feel free to reach out.
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. |
-
net8.0
- Microsoft.AspNetCore.Mvc.Abstractions (>= 2.2.0)
- Microsoft.AspNetCore.Mvc.Core (>= 2.2.5)
- Microsoft.AspNetCore.StaticFiles (>= 2.2.0)
- Microsoft.Extensions.FileProviders.Embedded (>= 8.0.7)
- MongoDB.Bson (>= 2.25.0)
- MongoDB.Driver (>= 2.25.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.