Search Results for

    Show / Hide Table of Contents

    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.

    Inheritance
    object
    SemanticLogMessageFormatter
    Implements
    ILogMessageFormatter
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.ReferenceEquals(object, object)
    object.ToString()
    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 Source

    Instance

    Gets the singleton instance of the SemanticLogMessageFormatter.

    Declaration
    public static readonly SemanticLogMessageFormatter Instance
    Field Value
    Type Description
    SemanticLogMessageFormatter

    Methods

    | Edit this page View Source

    Format(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

    | Edit this page View Source

    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

    Implements

    ILogMessageFormatter

    Extension Methods

    ObjectExtensions.IsDefaultForType<T>(T)
    ObjectExtensions.AsOption<T>(T)
    Extensions.AsInstanceOf<T>(object)
    In this article
    • githubEdit this page
    • View Source
    Back to top
    Contribute
    • Project Chat
    • Discussion Forum
    • Source Code
    Support
    • Akka.NET Support Plans
    • Akka.NET Observability Tools
    • Akka.NET Training & Consulting
    Maintained By
    • Petabridge - The Akka.NET Company
    • Learn Akka.NET