public void log(final Object iRequester, final Level iLevel, final String iMessage, final Throwable iException,
final Object... iAdditionalArgs) {
if (iMessage == null)
return;
final Logger log = iRequester != null ? Logger.getLogger(iRequester.getClass().getName()) : Logger.getLogger("");
if (!log.isLoggable(iLevel))
return;
final StringBuilder buffer = new StringBuilder();
buffer.append('\n');
synchronized (dateFormat) {
buffer.append(dateFormat.format(new Date()));
}
buffer.append(' ');
buffer.append(iLevel.getName().substring(0, 4));
if (iRequester != null) {
buffer.append(" [");
buffer.append(iRequester.getClass().getSimpleName());
buffer.append(']');
}
buffer.append(' ');
// FORMAT THE MESSAGE
try {
buffer.append(String.format(iMessage, iAdditionalArgs));
} catch (Exception e) {
buffer.append(iMessage);
}
if (iException != null)
log.log(iLevel, buffer.toString(), iException);
else
log.log(iLevel, buffer.toString());
}