Skip to content

Single-line Exception Formatting #131

@evrimsahin

Description

@evrimsahin

I'm trying to format exception details in a single line using ExpressionTemplate, but it's not working as expected.

Template I'm using:

"template": "{@t:yyyy-MM-dd HH:mm:ss.fff zzz}|{@l:u3}|{SourceContext}|{EventId}|{Replace(@m, '\n', ' ')}{#if @x} | Exception: {Replace(@x, '\n', ' ')}{#end}\n"

Actual result:

2025-08-04 10:28:33.244 +03:00|ERR|Microsoft.EntityFrameworkCore.Query|{"Id":10100,"Name":"Microsoft.EntityFrameworkCore.Query.QueryIterationFailed"}|An exception occurred while iterating over the results of a query for context type ''.
System.InvalidOperationException: An exception has been raised that is likely due to a transient failure.
---> Npgsql.NpgsqlException (0x80004005): Failed to connect to [::1]:5432
---> System.Net.Sockets.SocketException (10061): No connection could be made because the target machine actively refused it.
at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.ThrowException(SocketError error, CancellationToken cancellationToken)
...

Question:
Is there a way to ensure exception details are formatted in a single line with ExpressionTemplate? The Replace(@x, '\n', ' ') doesn't seem to affect the exception formatting.

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