From 3ff5d6c4fd7432be25eb153c4dcb83968bc7950b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20P=C3=A1nek?= Date: Tue, 29 Sep 2020 08:12:13 +0200 Subject: [PATCH] Decrease size of log output Only log the whole contents of an `Email` object on `trace` log level instead of `error`. Otherwise the whole email is printed to the logs, which can blow up the amount of logs quite a bit for services sending emails automatically. --- .../simplejavamail/mailer/internal/SendMailClosure.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/modules/simple-java-mail/src/main/java/org/simplejavamail/mailer/internal/SendMailClosure.java b/modules/simple-java-mail/src/main/java/org/simplejavamail/mailer/internal/SendMailClosure.java index 32840b8f5..946e11fc8 100644 --- a/modules/simple-java-mail/src/main/java/org/simplejavamail/mailer/internal/SendMailClosure.java +++ b/modules/simple-java-mail/src/main/java/org/simplejavamail/mailer/internal/SendMailClosure.java @@ -63,13 +63,16 @@ public void executeClosure() { TransportRunner.sendMessage(operationalConfig.getClusterKey(), session, message, message.getAllRecipients()); } } catch (final UnsupportedEncodingException e) { - LOGGER.error("Failed to send email:\n{}", email); + LOGGER.error("Failed to send email:\n{}", email.getId()); + LOGGER.trace("{}", email); throw new MailerException(MailerException.INVALID_ENCODING, e); } catch (final MessagingException e) { - LOGGER.error("Failed to send email:\n{}", email); + LOGGER.error("Failed to send email:\n{}", email.getId()); + LOGGER.trace("{}", email); throw new MailerException(MailerException.GENERIC_ERROR, e); } catch (final Exception e) { - LOGGER.error("Failed to send email:\n{}", email); + LOGGER.error("Failed to send email:\n{}", email.getId()); + LOGGER.trace("{}", email); throw e; } }