Logging In Loop (ARCH4164)
هذا المحتوى غير متوفر بلغتك بعد.
Key java.logging.logging-in-loop · Severity info · Category logging
Logging on every iteration of a loop floods log sinks with thousands of lines on large collections. Performance drops and important messages get lost in the noise.
Incorrect
Section titled “Incorrect”for (Order order : orders) { log.info("Processing: {}", order.id()); process(order);}Correct
Section titled “Correct”for (Order order : orders) { process(order);}log.info("Processed {} orders", orders.size());Move logging out of the loop into a single summary; if per-iteration logging is needed, use the trace/debug level.