我错过了什么?我有以下代码成功发送了一封电子邮件,但电子邮件的正文为空。我认为这与模式布局有关,但一切看起来都还不错。关于发生了什么的任何想法?
private void createAdminNotifyAppender(LoggerContext lc, AppConfigPropertiesReader propReader)
{
logger.info("Setting up logback admin_notify logging");
//Set up the admin notify appender programatically (needs to use the properties from the propReader above)
OnMarkerEvaluator markerEvaluator = new OnMarkerEvaluator();
markerEvaluator.addMarker(LogbackMarker.ADMIN_NOTIFY.toString());
String adminEmails = propReader.getProperty("adminEmail");
PatternLayout patternLayout = new PatternLayout();
patternLayout.setPattern("[\\(%-6threadHash\\) app=iv %d{yyyy-MM-dd HH:mm:ss.SSS}] %-5level %-25logger{25} - %msg%n");
SMTPAppender adminNotifyAppender = new SMTPAppender();
adminNotifyAppender.setContext(lc);
adminNotifyAppender.setEvaluator(markerEvaluator);
adminNotifyAppender.setSMTPHost(propReader.getProperty("smtpHost"));
for (String adminEmail : adminEmails.split(",")) { adminNotifyAppender.addTo(adminEmail); };
adminNotifyAppender.setFrom(propReader.getProperty("sysEmailAddressNoReply"));
adminNotifyAppender.setSubject("System Alert! [" + propReader.getProperty("environment") + "]");
adminNotifyAppender.setLayout(patternLayout);
adminNotifyAppender.start();
Logger rootLogger = lc.getLogger(Logger.ROOT_LOGGER_NAME);
rootLogger.addAppender(adminNotifyAppender);
}