Ir al contenido

To string in log (ARCH1006)

Esta página aún no está disponible en tu idioma.

Key dotnet.logging.to-string-in-log · Severity info · Category logging

Calling ToString() manually on log parameters incurs a conversion cost even when the log level is disabled. Pass the object directly.

_logger.LogInformation("Order received {Order}", order.Id.ToString());
_logger.LogInformation("Order received {Order}", order.Id);

Remove the ToString() call and pass the value as-is; let the logging infrastructure handle formatting.