Aller au contenu

Logging In Loop (ARCH2164)

Ce contenu n’est pas encore disponible dans votre langue.

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

Log statements inside a loop body can flood log sinks and disk space over large iterations. This buries real events in noise and degrades performance.

for item in items:
logger.info("Processing: %s", item.id)
process(item)
for item in items:
process(item)
logger.info("Processed %d items", len(items))

Aggregate logs across the loop, or log only a summary or exceptions outside it.