AnointedAutomation.Logging
1.1.0
See the version list below for details.
dotnet add package AnointedAutomation.Logging --version 1.1.0
NuGet\Install-Package AnointedAutomation.Logging -Version 1.1.0
<PackageReference Include="AnointedAutomation.Logging" Version="1.1.0" />
<PackageVersion Include="AnointedAutomation.Logging" Version="1.1.0" />
<PackageReference Include="AnointedAutomation.Logging" />
paket add AnointedAutomation.Logging --version 1.1.0
#r "nuget: AnointedAutomation.Logging, 1.1.0"
#:package AnointedAutomation.Logging@1.1.0
#addin nuget:?package=AnointedAutomation.Logging&version=1.1.0
#tool nuget:?package=AnointedAutomation.Logging&version=1.1.0
AnointedAutomation.Logging
Jesus is King ✝️
A small log message model for .NET. LogMessage captures the message, severity, timestamp, program name and calling method, and raises a static event every time one is created so you can route logs wherever you like.
Installation
dotnet add package AnointedAutomation.Logging
- Target framework:
net10.0 - Dependencies: Microsoft.Extensions.Logging.Abstractions (only for the
LogMessageLoggerILogger adapter)
Quick start
using System;
using AnointedAutomation.Optimization.Logging;
// Name your program once at startup; every LogMessage copies it into messageSource.
LogMessage.MessageSourceSetter = "MyApplication";
// Subscribe once; the event fires from every LogMessage constructor.
LogMessage.LogAdded += (sender, e) =>
{
Console.WriteLine($"{e.log.timeStamp:O} [{e.log.messageType}] {e.log.localOperationName}: {e.log.message}");
};
LogMessage.Info("Application started.");
LogMessage.Warning(42, "Cache miss rate is high.");
LogMessage.Error("Could not reach the payment provider.");
try { /* ... */ }
catch (Exception ex)
{
LogMessage.Error("Order 1001 capture failed", ex); // keeps the type, inner exceptions and stack
}
Note the namespace: the types live in AnointedAutomation.Optimization.Logging, not AnointedAutomation.Logging.
API overview
All types are in the AnointedAutomation.Optimization.Logging namespace.
LogMessage
| Member | Description |
|---|---|
LogMessage() |
Empty instance for object initializers. Raises no event and stamps nothing: a message built this way never reaches a LogAdded subscriber (your log store or alerts). |
LogMessage(MessageType messageType, string message) |
Sets timeStamp (DateTime.UtcNow), messageSource, localOperationName (stack walk) and raises LogAdded. |
LogMessage(long id, MessageType messageType, string message) |
Same as above, with an id. |
static string MessageSourceSetter |
Program name copied into every new message's messageSource. |
static event LogAddedEventHandler LogAdded |
Raised whenever a message is constructed with a type and text. Each subscriber runs in isolation: one that throws is reported on Console.Error and never breaks the caller. |
long id |
Optional identifier. |
string localOperationName |
Factories: the exact call site as File.Member:line (compiler caller info, no stack walk). Typed constructors: the calling method from the stack (Namespace.Class.Method). |
string message |
The log text. |
string messageSource |
Program name (from MessageSourceSetter). |
MessageType messageType |
Severity. |
DateTime timeStamp |
UTC creation time. |
string exceptionType |
Full type name of the exception passed to an exception overload. |
string callerMemberName / callerFilePath / int callerLineNumber |
Call site recorded by the factories. |
string category / storeSlug / properties |
Optional context for bridges and multi-tenant apps (category, tenant, JSON properties). |
Static factory methods, each with a (string message) and a (long id, string message) overload. Critical, Error and Warning also take (string message, Exception exception), which appends the full exception (type, inner exceptions, stack with file:line) to the message:
| Factory | Produces |
|---|---|
LogMessage.Celebrate |
MessageType.Celebrate |
LogMessage.Critical |
MessageType.Critical |
LogMessage.Error |
MessageType.Error |
LogMessage.Info / LogMessage.Informational |
MessageType.Informational |
LogMessage.Message |
MessageType.Message |
LogMessage.Success |
MessageType.Success |
LogMessage.Warning |
MessageType.Warning |
LogMessageEventArgs
EventArgs passed to LogAdded; the message is exposed as the log property. The delegate is LogMessage.LogAddedEventHandler(object sender, LogMessageEventArgs e).
MessageType
enum MessageType : int
| Value | Number | Meaning |
|---|---|---|
Error |
0 | An error that should be investigated |
Warning |
1 | A potential issue |
Success |
2 | A successful operation |
Informational |
3 | General information |
Message |
4 | A general message with no severity |
Critical |
5 | A severe error needing immediate attention |
Celebrate |
6 | A milestone or achievement |
Notes
LogAddedis a static event. EveryLogMessagecreated anywhere in the process reaches every subscriber, so subscribe once and unsubscribe when your listener goes away.- The factories record the caller with
[CallerMemberName]/[CallerFilePath]/[CallerLineNumber]at no runtime cost; only the typed constructors capture aStackTrace. - Since 1.0.7 the package ships an embedded portable PDB, so stack traces through it show file and line.
Related packages
Other AnointedAutomation packages build on this one and expose their own log buffers of LogMessage:
- AnointedAutomation.APIMiddlewares
- AnointedAutomation.Repository.Mongo
- AnointedAutomation.Repository.MySql
License
MIT. See LICENSE.
Support This Project
This library is free and open source. The best way to support the work is to shop with us:
- Christian items: https://store.anointed.company
- Pets: https://www.animaldander.com
- Everything else: https://www.mart.club
Found a bug or have a request? Open an issue at https://github.com/AnointedAutomation/AnointedAutomation/issues.
Structured logging (1.1.0)
// Up to four properties inline; they land in structuredProperties and, as JSON, in properties.
LogMessage.Warning($"Refund failed for order {orderId}", ex, ("orderId", orderId), ("store", storeSlug));
LogMessage.Debug($"cache miss {key}"); // MessageType.Debug = 7, Trace = 8 (appended, never renumbered)
// Scopes flow through awaits and tasks (AsyncLocal); inner scopes and call-site values win on a repeated key.
using IDisposable scope = LogMessage.Scope(("orderId", orderId));
// category is the caller file name ("OrderService") by default; For<T>() stamps the type's full name instead.
private static readonly LogSource Log = LogMessage.For<OrderService>();
Log.Error("capture failed", ex, ("orderId", orderId));
| Type | Purpose |
|---|---|
LogStoreCapture |
Test helper: using LogStoreCapture capture = LogStoreCapture.Start(); records the messages of the current async flow only, so parallel xUnit/NUnit tests never see each other's logs. Entries, OfLevel, Contains. |
LogStoreThrottle |
Shared store throttle: 5 identical rows, 50 per template (200 for Errors) per 10-minute window, Critical never throttled; TakeSummaries(force) returns one summary per key that suppressed rows. |
LogMessageLogger / LogMessageLoggerProvider |
ILogger adapter for third-party APIs that require one; writes through LogMessage with state pairs as properties. |
Startup ordering (opt-in): call LogMessage.BufferUntilFirstSubscriber() first thing in Main; messages raised before the
first LogAdded subscriber attaches are then buffered (up to LogMessage.PreSubscriptionBufferCapacity, 1000; oldest
dropped) and delivered to that subscriber, followed by one Warning with the dropped count if any were dropped. Off by
default, so libraries and test runs never hold or replay stale messages. LogAdded handlers run synchronously on the logging thread: keep them fast and
queue any I/O.
| Product | Versions 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. |
-
net10.0
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.15)
NuGet packages (7)
Showing the top 5 NuGet packages that depend on AnointedAutomation.Logging:
| Package | Downloads |
|---|---|
|
AnointedAutomation.Repository.Mongo
A MongoDB helper and generic repository base for .NET, with CRUD, paging, aggregation, index management, BSON class maps and casing conventions. |
|
|
AnointedAutomation.APIMiddlewares
ASP.NET Core middleware and filters for API key authentication, IP blacklisting, country blocking, honeypot and bot defense, invalid endpoint tracking and idle time memory cleanup. |
|
|
AnointedAutomation.Memory
On demand garbage collection helper that forces a full collection and tries to return unused memory to the operating system. |
|
|
AnointedAutomation.Serialization
Shared serialization helpers: naming rules (camel, Pascal, snake and the hybrid value/reference casing rule), System.Text.Json casing convention, presets and UTC DateTime converter, tolerant Newtonsoft.Json converters, and lenient JsonElement readers. No MongoDB dependency. |
|
|
AnointedAutomation.Concepts
Models Biblical concepts as .NET types: love as a behavior tree, a moral reality that reads acts against God's character, and an epistemics engine that checks claims for consistency. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.1.1 | 0 | 11/18/2026 |
| 1.1.0 | 1,190 | 11/13/2026 |
| 1.0.8 | 3,479 | 11/4/2026 |
| 1.0.6 | 746 | 10/26/2026 |
| 1.0.5 | 601 | 10/1/2026 |
| 1.0.4 | 169 | 10/1/2026 |
| 1.0.3 | 297 | 9/25/2026 |
| 1.0.2 | 655 | 8/23/2026 |
| 1.0.1 | 1,287 | 5/30/2026 |
| 1.0.0 | 1,040 | 3/15/2026 |
| 0.0.10 | 327 | 3/13/2026 |
| 0.0.9 | 217 | 3/11/2026 |
| 0.0.8 | 788 | 2/17/2026 |