NaNTech.MongoDB.ULog 1.1.0.4

There is a newer version of this package available.
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                
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="NaNTech.MongoDB.ULog" Version="1.1.0.4" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add NaNTech.MongoDB.ULog --version 1.1.0.4                
#r "nuget: NaNTech.MongoDB.ULog, 1.1.0.4"                
#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.
// 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 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. 
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.1.0.6 0 7/19/2024
1.1.0.5 0 7/19/2024
1.1.0.4 0 7/19/2024
1.0.0 84 5/3/2024