Zum Inhalt springen

Logging In Loop (ARCH3164)

Dieser Inhalt ist noch nicht in deiner Sprache verfügbar.

Key typescript.logging.logging-in-loop · Severity info · Category logging

Log statements inside a loop body can flood log sinks over large collections. This raises storage cost and buries real events in noise.

function importRows(rows: Row[]) {
for (const row of rows) {
logger.info("processing row", { id: row.id });
process(row);
}
}
function importRows(rows: Row[]) {
for (const row of rows) {
process(row);
}
logger.info("rows processed", { count: rows.length });
}

Aggregate results and write a single summary log outside the loop instead of logging per iteration.