This is expensive:
_logger.LogInformation($"User {id} logged in");
✅ Correct Way
_logger.LogInformation("User {UserId} logged in", id);
Why
-
Avoids string interpolation
-
Enables structured logging
-
Reduces allocations
Daily micro-tips for C#, SQL, performance, and scalable backend engineering.
This is expensive:
_logger.LogInformation($"User {id} logged in");
✅ Correct Way
_logger.LogInformation("User {UserId} logged in", id);
Why
Avoids string interpolation
Enables structured logging
Reduces allocations