From a367e730250b39efd2f577f3802281711f1d1bb8 Mon Sep 17 00:00:00 2001 From: Michael Seaton Date: Fri, 6 Oct 2023 17:06:18 -0400 Subject: [PATCH] =?UTF-8?q?TRUNK-6196:=20Email=20sending=20fails=20due=20t?= =?UTF-8?q?o=20errors=20with=20velocity=20log=20conf=E2=80=A6=20(#4399)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mail/velocity/VelocityMessagePreparator.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/api/src/main/java/org/openmrs/notification/mail/velocity/VelocityMessagePreparator.java b/api/src/main/java/org/openmrs/notification/mail/velocity/VelocityMessagePreparator.java index 1517b5205fa4..588341b742c9 100644 --- a/api/src/main/java/org/openmrs/notification/mail/velocity/VelocityMessagePreparator.java +++ b/api/src/main/java/org/openmrs/notification/mail/velocity/VelocityMessagePreparator.java @@ -10,9 +10,11 @@ package org.openmrs.notification.mail.velocity; import java.io.StringWriter; +import java.util.Properties; import org.apache.velocity.VelocityContext; import org.apache.velocity.app.VelocityEngine; +import org.apache.velocity.runtime.log.Log4JLogChute; import org.openmrs.notification.Message; import org.openmrs.notification.MessageException; import org.openmrs.notification.MessagePreparator; @@ -40,7 +42,11 @@ public class VelocityMessagePreparator implements MessagePreparator { public VelocityMessagePreparator() throws MessageException { try { engine = new VelocityEngine(); - engine.init(); + Properties props = new Properties(); + props.put("runtime.log.logsystem.class", Log4JLogChute.class.getName()); + props.put("runtime.log.logsystem.log4j.category", "velocity"); + props.put("runtime.log.logsystem.log4j.logger", "velocity"); + engine.init(props); } catch (Exception e) { log.error("Failed to create velocity engine " + e.getMessage(), e);