Class SemanticLogMessageFormatter
Message formatter that supports semantic logging with both positional and named templates. Implements the Message Templates specification, which is the language-neutral standard used by Serilog, Microsoft.Extensions.Logging, NLog, and other structured logging frameworks.
Implements
Inherited Members
Namespace: Akka.Event
Assembly: Akka.dll
Syntax
public sealed class SemanticLogMessageFormatter : ILogMessageFormatter
Remarks
Supported syntax:
- Named properties:
{PropertyName} - Positional properties:
{0},{1} - Format specifiers:
{Value:N2},{Date:yyyy-MM-dd} - Alignment:
{Value,10},{Value,-10} - Escaped braces:
{{→{,}}→}
Not supported:
- Destructuring operators:
{@Object},{$Object}(Serilog-specific) - Empty property names:
{:N2}(invalid per spec)
Null handling: Named templates (e.g., {PropertyName}) render null values
as the literal string "null". This is consistent with the Message Templates specification
and matches the behavior of Serilog, NLog, and other structured logging frameworks.
In contrast, positional templates (e.g., {0}) delegate to Format(string, params object[]),
which renders null as an empty string "". This asymmetry is by design:
positional templates preserve backward compatibility with DefaultLogMessageFormatter,
while named templates follow the Message Templates spec.
Fields
| Edit this page View SourceInstance
Gets the singleton instance of the SemanticLogMessageFormatter.
Declaration
public static readonly SemanticLogMessageFormatter Instance
Field Value
| Type | Description |
|---|---|
| SemanticLogMessageFormatter |
Methods
| Edit this page View SourceFormat(string, IEnumerable<object>)
Formats a log message using the specified format string and arguments.
Declaration
public string Format(string format, IEnumerable<object> args)
Parameters
| Type | Name | Description |
|---|---|---|
| string | format | The format string (supports both {0} and {PropertyName} styles) |
| IEnumerable<object> | args | The arguments to format |
Returns
| Type | Description |
|---|---|
| string | The formatted message string |
Format(string, params object[])
Formats a log message using the specified format string and arguments.
Declaration
public string Format(string format, params object[] args)
Parameters
| Type | Name | Description |
|---|---|---|
| string | format | The format string (supports both {0} and {PropertyName} styles) |
| object[] | args | The arguments to format |
Returns
| Type | Description |
|---|---|
| string | The formatted message string |
Edit this page