Skip to content

Automatically convert ILoggingAdapter into SerilogLoggingAdapter when FromContext is called. #284

@Aaronontheweb

Description

@Aaronontheweb

Is your feature request related to a problem? Please describe.

https://stackoverflow.com/questions/78400210/akka-net-1-5-serilog-logger-not-adding-extra-properties-when-using-forcontext/78410544?noredirect=1#comment138457383_78410544 - we promised to do this during our May 2024 Akka.NET Community Standup:

https://petabridge.notion.site/5-15-2024-Akka-NET-Community-Standup-0b6a6dd4ca2f4a0e974056afe744ebb5?pvs=4

https://www.youtube.com/watch?v=jOBFvXW1nUc

Describe the solution you'd like

Basically, this should just return a SerilogLoggingAdapter implicitly - even if the underlying ILoggingAdapter used one of the built-in Akka.NET default implementations of LoggingAdapterBase:

  // this way does NOT render the FromContext property in the output, contrary to documentation
 Context.GetLogger()
            .ForContext("FromContextProperty", "bbb")
            .Error("NEW WAY {FromMessageProperty}", txt);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions