Plugin.Maui.ActivityLogger 1.0.0

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

Plugin.Maui.ActivityLogger

Plugin.Maui.ActivityLogger is a single-package .NET 10 MAUI activity logging library for enterprise mobile, MAUI Hybrid, and offline-first applications.

It provides user activity logs, audit trails, page tracking, API request logging, error tracking, session tracking, SQLite offline storage, batch synchronization, SignalR realtime streaming, sensitive data masking, optional metadata encryption, and HttpClientFactory integration.

Install

dotnet add package Plugin.Maui.ActivityLogger

Configure

using Plugin.Maui.ActivityLogger.Extensions;

builder
    .UseMauiApp<App>()
    .AddActivityLogger(options =>
    {
        options.ApiEndpoint = "https://api.company.com";
        options.SignalRHub = "https://api.company.com/activityHub";
        options.Endpoints.LogEndpoint = "https://api.company.com/logs";
        options.Endpoints.ErrorEndpoint = "https://api.company.com/errors";
        options.Endpoints.ApiLogEndpoint = "https://api.company.com/api-logs";
        options.EnableOfflineMode = true;
        options.EnableRealtimeTracking = true;
        options.EnableApiLogging = true;
        options.EnableScreenTracking = true;
        options.UseSQLite = true;
        options.BatchSize = 100;
        options.SyncIntervalSeconds = 30;
        options.ConfigureHttpClient = client =>
        {
            client.DefaultRequestHeaders.Add("Authorization", "Bearer token");
        };
        options.PayloadTransformer = payload =>
        {
            payload.Metadata["Company"] = "ABC";
            return payload;
        };
    });

builder.Services
    .AddHttpClient("CompanyApi")
    .AddActivityLogging();

return builder.Build().UseActivityLogger();

For non-MAUI shared services or tests:

services.AddActivityLogger(options =>
{
    options.UseSQLite = true;
    options.EnableRealtimeTracking = false;
});

Usage

await logger.LogActionAsync("CREATE_MANIFEST", "User created manifest");
await logger.LogErrorAsync(ex);
await logger.TrackPageAsync("DashboardPage");
await sessionTracker.LoginAsync(userId);
await sessionTracker.LogoutAsync();
await syncService.SyncAsync();

Architecture

The NuGet package is intentionally one package and one assembly. Internally it is organized by folders:

  • Core: public interfaces.
  • Models: activity, API, error, session, device, and payload models.
  • Storage: EF Core SQLite storage and in-memory test storage.
  • Http: DelegatingHandler for API logging.
  • Realtime: SignalR client and no-op realtime service.
  • Tracking: page and crash tracking.
  • Session: session lifecycle tracking.
  • Sync: connectivity detection, batch sync, and background worker.
  • Extensions: dependency injection and MAUI activation.
  • Helpers: JSON, masking, and encryption helpers.
  • Options: configuration surface.

No API URLs, routes, hubs, authentication, server contracts, or payload transformations are hardcoded. The consuming app owns all backend endpoints, auth headers, access tokens, and payload enrichment.

Backend Contract

The sync engine posts JSON arrays to the configured endpoints:

  • Endpoints.LogEndpoint: ActivityLog[]
  • Endpoints.ApiLogEndpoint: ApiLog[]
  • Endpoints.ErrorEndpoint: ErrorLog[]
  • Endpoints.SessionEndpoint: SessionLog[]

Successful 2xx responses mark rows as synced. 5xx, network failures, and timeouts are retried with Polly and left queued if they still fail.

Database

SQLite tables are created automatically with EF Core:

  • ActivityLogs: Id, UserId, Action, Description, Page, Timestamp, Duration, DeviceInfo, Platform, IsSynced, MetadataJson
  • ApiLogs: Id, Url, Method, StatusCode, Duration, ErrorMessage, Timestamp, RetryCount, WasOffline, IsSynced
  • ErrorLogs: Id, Message, StackTrace, Source, Timestamp, DeviceInfo, IsSynced
  • SessionLogs: Id, SessionId, UserId, Event, Timestamp, Duration, IsSynced

Set options.DatabasePath to control the database location.

Security

The default masker redacts bearer tokens, token-like query string parameters, passwords, and common secret JSON fields before persistence. Set options.EncryptionKey to encrypt metadata/device JSON stored by the default services. For stricter policies, use PayloadTransformer and custom service registrations.

Realtime

Set EnableRealtimeTracking = true and SignalRHub to enable live streaming. The SignalR client uses automatic reconnect. Use AccessTokenProvider or ConfigureHttpClient for authentication.

Sample

The sample app is under samples/ActivityLogger.Sample and demonstrates:

  • Login/session tracking.
  • Custom action logging.
  • HttpClientFactory API logging.
  • Handled error logging.
  • Offline SQLite queueing.
  • Realtime configuration.

Build it on Windows:

dotnet build samples/ActivityLogger.Sample/ActivityLogger.Sample.csproj -f net10.0-windows10.0.19041.0

Testing

dotnet test tests/Plugin.Maui.ActivityLogger.Tests/Plugin.Maui.ActivityLogger.Tests.csproj

The test suite covers in-memory logging, sensitive data masking, page duration tracking, and SQLite persistence.

Publish to NuGet

Update package metadata in src/Plugin.Maui.ActivityLogger/Plugin.Maui.ActivityLogger.csproj, then run:

dotnet pack src/Plugin.Maui.ActivityLogger/Plugin.Maui.ActivityLogger.csproj -c Release
dotnet nuget push src/Plugin.Maui.ActivityLogger/bin/Release/Plugin.Maui.ActivityLogger.1.0.0.nupkg --api-key <key> --source https://api.nuget.org/v3/index.json

The project enables XML documentation, nullable reference types, SourceLink, and .snupkg symbols.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-android36.0 is compatible.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-ios26.0 is compatible.  net10.0-maccatalyst was computed.  net10.0-maccatalyst26.0 is compatible.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed.  net10.0-windows10.0.19041 is compatible. 
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.0 91 5/26/2026