Skip to content

Fix performance bottleneck with ILogger string interpolation #126

Closed

Description

@goodtocode

Use:

using Microsoft.Extensions.Logging;

namespace Cannery.Insights.Core.Application.Common
{
public static partial class CustomLoggingBehaviorExtensions
{
[LoggerMessage(EventId = 100, Level = LogLevel.Information, Message = "Request: {Name}")]
public static partial void LogRequest(this ILogger logger, string name);

    [LoggerMessage(EventId = 101, Level = LogLevel.Warning, Message = "Long Running Request: {Name} ({ElapsedMilliseconds} milliseconds)")]
    public static partial void LogLongRunningRequest(this ILogger logger, string name, long elapsedMilliseconds);

    [LoggerMessage(EventId = 102, Level = LogLevel.Error, Message = "Request: Unhandled Exception for Request {Name}")]
    public static partial void LogUnhandledException(this ILogger logger, Exception exception, string name);
}

}

Activity

  1. linked a pull request that will close this issuenull check fix #137on Feb 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions