void () { if (myStackOverflowProtection.get()) { if (myStackOverflowProtectionTriggered.compareAndSet(false, true)) { myLogger.error("Stack overflow protection triggered in logger. A standard stream overridden to write to logs?"); } return; } myStackOverflowProtection.set(true); try { myLogger.info(new String(myBuffer, 0, myPosition, Charset.defaultCharset())); myPosition = 0; } finally { myStackOverflowProtection.set(false); } }