Egov.Integrations.MLog 10.0.1

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

Egov.Integrations.MLog

NuGet Version License: MIT

A production-ready C# library for integrating with MLog services. This library provides a clean and easy-to-use client to register and query events using secure certificate-based authentication, designed for modern cloud-native and microservices architectures.


Table of Contents


Features

  • Simple Event Registration: Register single events or batches of events with a rich metadata model.
  • Advanced Querying: Search for events by UID or time range with customizable filtering.
  • Secure Authentication: Built-in support for mutual TLS (mTLS) using certificate-based authentication.
  • Dependency Injection: Seamless integration with standard .NET dependency injection (IServiceCollection).
  • Asynchronous API: Native support for async/await patterns for non-blocking I/O.
  • Modern .NET: Built for .NET 10+ leveraging the latest runtime improvements.

Prerequisites

  • .NET 10.0 or later
  • Valid MLog client certificate for authentication

Installation

Install the package via NuGet:

dotnet add package Egov.Integrations.MLog

Configuration

The library uses MLogClientOptions for configuration. You can configure it via appsettings.json or in code.

appsettings.json

{
  "MLog": {
    "BaseAddress": "https://mlog.staging.egov.md:8443"
  },
  "Certificate": {
    "Path": "path/to/your/certificate.pfx",
    "Password": "your_password"
  }
}

Dependency Injection Setup

Register the MLog client in your Program.cs:

using Egov.Integrations.MLog;

var builder = WebApplication.CreateBuilder(args);

// Add certificate support (from Age.Extensions.Configuration)
builder.Services.AddSystemCertificate(builder.Configuration.GetSection("Certificate"));

// Add MLog Client
builder.Services.AddMLogClient(builder.Configuration.GetSection("MLog"));

var app = builder.Build();

Usage

Registering an Event

Use the IMLogClient to register events fluently:

using Egov.Integrations.MLog;
using Egov.Integrations.MLog.Models;

public class MyService(IMLogClient mlogClient)
{
    public async Task LogSomethingAsync()
    {
        var mlogEvent = new MLogEvent("my.app.event")
        {
            EventID = Guid.NewGuid().ToString("D"),
            EventCorrelation = "corr-123",
            EventMessage = "Something important happened",
            EventLevel = "INFO",
            EventTime = DateTime.UtcNow,
            User = "user-id-789"
        };

        string eventId = await mlogClient.RegisterEventAsync(mlogEvent);
        Console.WriteLine($"Event registered with ID: {eventId}");
    }
}

Querying Events

Query events based on time ranges and legal context:

public async Task SearchEventsAsync(IMLogClient mlogClient)
{
    var from = DateTime.UtcNow.AddDays(-1);
    var to = DateTime.UtcNow;
    var legalBasis = "Law 123/2023, Art 5";

    string results = await mlogClient.QueryEventsAsync(from, to, legalBasis);
    Console.WriteLine(results);
}

Testing

The solution includes a comprehensive test suite using xUnit.

Running the tests

dotnet test src/Egov.Integrations.MLog.sln

Contributing

Contributions are welcome! Please read CONTRIBUTING.md for guidelines on how to get started.


Code of Conduct

This project adheres to the Contributor Covenant Code of Conduct. By participating, you are expected to uphold this code.


AI Assistance

This repository contains an AGENTS.md file with instructions and context for AI coding agents to assist in development, ensuring consistency in code style and project structure.


License

This project is licensed under the MIT License.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  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
10.0.1 157 4/14/2026