If performance is not a big issue, I would use the following
if(Math.Log10(count) % 1 == 0) _logger.LogFormattable(LogLevel.Debug, $"{count} Rows Read");
This question reads as follows:
For floating point numbers, n% 1 == 0 is usually a way to check if there is anything beyond the decimal point.
Edit: to complete my answer, you can also track the following registration value, as @ Übercoder sent in his answer.
long nextLoggingValueForLogX = 1; if (count == nextLoggingValueForLogX ) { nextLoggingValueForLogX *= 10; // Increase it by your needs, eg, logarithmically by multiplying with 10 _logger.LogFormattable(LogLevel.Debug, $"{count} Rows Read"); }
However, this method will have a new variable for each log, which should not be executed every time. This will add extra code as well as extra work if it should be thread safe.
source share