SunAuto.Logging 1.0.0

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

SunAuto.Logging

A standard Microsoft.Extensions.Logging provider for Sun Auto applications. Supports console output, a custom sink delegate, and built-in forwarding to a Splunk HTTP Event Collector (HEC).

Target Frameworks

net8.0 · net9.0 · net10.0 · netstandard2.1

Installation

dotnet add package SunAuto.Logging

Usage

Generic Host / ASP.NET Core

var builder = WebApplication.CreateBuilder(args);

builder.Logging.ClearProviders();
builder.Logging.AddSunAutoLogging(options =>
{
    options.MinimumLevel    = LogLevel.Information;
    options.IncludeScopes   = true;
    options.IncludeTimestamp = true;
});

Configuration via appsettings.json

{
  "Logging": {
    "SunAuto": {
      "MinimumLevel": "Information",
      "IncludeScopes": true,
      "IncludeTimestamp": true,
      "TimestampFormat": "yyyy-MM-ddTHH:mm:ss.fffZ"
    }
  }
}

Then register without a configuration delegate:

builder.Logging.AddSunAutoLogging();

Custom Sink

Route log output to any destination by supplying a Sink delegate:

builder.Logging.AddSunAutoLogging(options =>
{
    options.Sink = line => MyExternalSystem.Write(line);
});

When Sink is null (the default) and no Splunk options are configured, output goes to Console.Out.

Splunk HEC

Set all three Splunk options to enable automatic forwarding to a Splunk HTTP Event Collector. Log entries are batched and posted asynchronously.

builder.Logging.AddSunAutoLogging(options =>
{
    options.Splunk = new()
    {
        BaseUrl = "https://splunk-host:8088/",
        Token   = "<your-hec-token>",
        Source  = "my-api",
    };
});

Or via appsettings.json:

{
    "Logging": {
        "SunAuto": {
            "LogLevel": {
                "Default": "Information"
            },
            "Splunk": {
                "BaseUrl": "https://your-splunk-host:8088/",
                "Token": "your-hec-token",
                "Source": "my-app-sourcetype"
            }
        }
}

All three fields (Splunk.BaseUrl, Splunk.Token, Splunk.Source) must be present for the Splunk sink to activate. If a custom Sink delegate is also provided, it takes precedence and the Splunk sink is not created.

Options

Property Type Default Description
MinimumLevel LogLevel Information Lowest level that is emitted
IncludeScopes bool true Append active log scopes to each line
IncludeTimestamp bool true Prepend a UTC timestamp to each line
TimestampFormat string "yyyy-MM-ddTHH:mm:ss.fffZ" DateTime format string for the timestamp
Sink Action<string>? null (→ Console) Custom output target; takes precedence over Splunk
Splunk SplunkOptions? null Splunk HEC settings; all three sub-properties required
Splunk.BaseUrl string? null HEC base URL (e.g. https://splunk-host:8088/)
Splunk.Token string? null HEC authentication token
Splunk.Source string? null Splunk sourcetype assigned to every event

Log Format

[2026-05-19T14:32:01.123Z] info MyApp.Services.RepairService: Order 1042 authorised. => Scope

Level labels: trce · dbug · info · warn · fail · crit

Contributing

Pull requests are welcome. For major changes, please open an issue first.

Run the unit tests before submitting:

dotnet test ../ClientTest/ClientTest.csproj

Please make sure to update tests as appropriate.

Support

If you like this project and think it has helped in any way, consider getting tires or auto service at a Sun Auto Tire & Service location near you:

<a href="https://sun.auto/home" target="_blank"><img src="https://sun.auto/wp-content/themes/sun-auto/images/logo_sunauto.png" alt="Sun Auto Tire & Service" width="150" height="65"/></a>

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  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 is compatible.  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 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. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos 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.0.0 103 5/30/2026
1.0.0-preview 115 5/22/2026