SunAuto.Logging
1.1.1
See the version list below for details.
dotnet add package SunAuto.Logging --version 1.1.1
NuGet\Install-Package SunAuto.Logging -Version 1.1.1
<PackageReference Include="SunAuto.Logging" Version="1.1.1" />
<PackageVersion Include="SunAuto.Logging" Version="1.1.1" />
<PackageReference Include="SunAuto.Logging" />
paket add SunAuto.Logging --version 1.1.1
#r "nuget: SunAuto.Logging, 1.1.1"
#:package SunAuto.Logging@1.1.1
#addin nuget:?package=SunAuto.Logging&version=1.1.1
#tool nuget:?package=SunAuto.Logging&version=1.1.1
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;
});
Configuration via appsettings.json
{
"Logging": {
"SunAuto": {
"MinimumLevel": "Information",
"LogLevel": {
"Default": "Information"
}
}
}
}
Then register without a configuration delegate:
builder.Logging.AddSunAutoLogging();
Custom Sink
Route log output to any destination by supplying a Sink delegate. The delegate receives a
QueueEntry, which carries the level, event ID, formatted message, exception and timestamp:
builder.Logging.AddSunAutoLogging(options =>
{
options.Sink = entry => MyExternalSystem.Write(entry.Formatted, entry.Exception);
});
QueueEntry.ToString() renders the same single-line format used by the console fallback, so
options.Sink = entry => MyExternalSystem.Write(entry.ToString()); also works.
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. Entries are queued and posted asynchronously on a background task, so logging never blocks the caller. Entries that arrive while a post is in flight are coalesced into the next request.
builder.Logging.AddSunAutoLogging(options =>
{
options.Splunk = new()
{
BaseUrl = "https://splunk-host:8088/",
Token = builder.Configuration["Splunk:Token"],
Source = "my-api",
};
});
Or via configuration:
{
"Logging": {
"SunAuto": {
"LogLevel": {
"Default": "Information"
},
"Splunk": {
"BaseUrl": "https://your-splunk-host:8088/",
"Source": "my-app-sourcetype"
}
}
}
}
Keep the HEC token out of appsettings.json. Supply it through User Secrets in development
and an environment variable or secret store in deployed environments, so it is never committed:
dotnet user-secrets set "Logging:SunAuto:Splunk:Token" "<your-hec-token>"
export Logging__SunAuto__Splunk__Token="<your-hec-token>"
All three fields (Splunk.BaseUrl, Splunk.Token, Splunk.Source) must be present for the Splunk
sink to activate; if any is missing the sink is skipped and output falls back to the console. If a
custom Sink delegate is also provided, it takes precedence and the Splunk sink is not created.
BaseUrl should include a trailing slash if it contains a path. https://host:8088/api resolves
to https://host:8088/services/collector/event, dropping the /api segment; https://host:8088/api/
resolves as expected. A bare host with no path is unaffected.
Options
| Property | Type | Default | Description |
|---|---|---|---|
MinimumLevel |
LogLevel |
Information |
Lowest level that is emitted |
Sink |
Action<QueueEntry>? |
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 |
MinimumLevel is applied in addition to the standard Logging:SunAuto:LogLevel filters, so a
message must satisfy both to be emitted.
Not yet implemented.
IncludeScopes,IncludeTimestampandTimestampFormatexist onLoggerOptionsbut are not currently applied to any output. Setting them has no effect.
Log Format
Console output (the fallback when no Sink and no Splunk options are configured) is a single line
per entry, produced by QueueEntry.ToString():
2026-05-19T14:32:01.1234567Z Information Order 1042 authorised.
2026-05-19T14:32:04.7654321Z Error [42] Charge failed. Exception: System.InvalidOperationException: gateway timeout
That is round-trip UTC timestamp, level name, event ID in brackets when non-zero, then the
formatted message, followed by an Exception: section when an exception is attached.
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 | Versions 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. |
-
.NETStandard 2.1
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.19)
- Microsoft.Extensions.Logging (>= 9.0.19)
- Microsoft.Extensions.Logging.Configuration (>= 9.0.19)
- Microsoft.Extensions.Options (>= 9.0.19)
- System.Text.Json (>= 9.0.19)
-
net10.0
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.19)
- Microsoft.Extensions.Logging (>= 9.0.19)
- Microsoft.Extensions.Logging.Configuration (>= 9.0.19)
- Microsoft.Extensions.Options (>= 9.0.19)
-
net8.0
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.19)
- Microsoft.Extensions.Logging (>= 9.0.19)
- Microsoft.Extensions.Logging.Configuration (>= 9.0.19)
- Microsoft.Extensions.Options (>= 9.0.19)
- System.Text.Json (>= 9.0.19)
-
net9.0
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.19)
- Microsoft.Extensions.Logging (>= 9.0.19)
- Microsoft.Extensions.Logging.Configuration (>= 9.0.19)
- Microsoft.Extensions.Options (>= 9.0.19)
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 |
|---|---|---|
| 2.0.0 | 341 | 8/16/2026 |
| 1.1.1 | 107 | 8/16/2026 |
| 1.0.0 | 454 | 5/30/2026 |
| 1.0.0-preview | 134 | 5/22/2026 |