if (LOG.isLoggable(Level.INFO) || writer != null) {
// Write the output while caching it for the log message
boolean hasLogged = message.containsKey(LOG_SETUP);
if (!hasLogged) {
message.put(LOG_SETUP, Boolean.TRUE);
final CacheAndWriteOutputStream newOut = new CacheAndWriteOutputStream(os);
message.setContent(OutputStream.class, newOut);
newOut.registerCallback(new LoggingCallback(message, os));
}
}
}