[EAGLE-968] Fix for email issue in 0.5 eagle version

<!--
{% comment %}
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements.  See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to you under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License.  You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
{% endcomment %}
-->

Be sure to do all of the following to help us incorporate your contribution
quickly and easily:

 - [ ] Make sure the PR title is formatted like:
   `[EAGLE-<Jira issue #>] Description of pull request`
 - [ ] Make sure tests pass via `mvn clean verify`. (Even better, enable
       Travis-CI on your fork and ensure the whole test matrix passes).
 - [ ] Replace `<Jira issue #>` in the title with the actual Jira issue
       number, if there is one.
 - [ ] If this contribution is large, please file an Apache
       [Individual Contributor License Agreement](https://www.apache.org/licenses/icla.txt).

---

Author: kreddylh <kreddylh@paypal.com>
Author: rushikesavareddy <keshav19@gmail.com>

Closes #941 from rushikesavareddy/branch-0.5.
diff --git a/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/main/java/org/apache/eagle/alert/engine/publisher/email/EagleMailClient.java b/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/main/java/org/apache/eagle/alert/engine/publisher/email/EagleMailClient.java
index 7147894..c7e02e0 100755
--- a/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/main/java/org/apache/eagle/alert/engine/publisher/email/EagleMailClient.java
+++ b/eagle-core/eagle-alert-parent/eagle-alert/alert-engine/src/main/java/org/apache/eagle/alert/engine/publisher/email/EagleMailClient.java
@@ -25,7 +25,6 @@
 import org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader;

 import org.slf4j.Logger;

 import org.slf4j.LoggerFactory;

-

 import java.io.File;

 import java.io.StringWriter;

 import java.util.ArrayList;

@@ -39,9 +38,9 @@
 import javax.mail.internet.*;

 

 public class EagleMailClient {

+    

     private static final Logger LOG = LoggerFactory.getLogger(EagleMailClient.class);

     private static final String BASE_PATH = "templates/";

-

     private VelocityEngine velocityEngine;

     private Session session;

 

@@ -54,6 +53,8 @@
             velocityEngine = new VelocityEngine();

             velocityEngine.setProperty(RuntimeConstants.RESOURCE_LOADER, "classpath");

             velocityEngine.setProperty("classpath.resource.loader.class", ClasspathResourceLoader.class.getName());

+            velocityEngine.setProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM_CLASS,org.apache.velocity.runtime.log.Log4JLogChute.class.getName());

+            velocityEngine.setProperty("runtime.log.logsystem.log4j.logger", LOG.getName());

             velocityEngine.init();

 

             config.put("mail.transport.protocol", "smtp");

@@ -61,16 +62,16 @@
                 session = Session.getInstance(config, new Authenticator() {

                     protected PasswordAuthentication getPasswordAuthentication() {

                         return new PasswordAuthentication(

-                            config.getProperty(AlertEmailConstants.CONF_AUTH_USER),

-                            config.getProperty(AlertEmailConstants.CONF_AUTH_PASSWORD)

-                        );

+                                config.getProperty(AlertEmailConstants.CONF_AUTH_USER),

+                                config.getProperty(AlertEmailConstants.CONF_AUTH_PASSWORD)

+                                );

                     }

                 });

             } else {

                 session = Session.getInstance(config, new Authenticator() {

                 });

             }

-

+            

             final String debugMode = config.getProperty(AlertEmailConstants.CONF_MAIL_DEBUG, "false");

             final boolean debug = Boolean.parseBoolean(debugMode);

             LOG.info("Set email debug mode: " + debugMode);

diff --git a/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/mail/EagleMailClient.java b/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/mail/EagleMailClient.java
index 81b1114..d15a60a 100644
--- a/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/mail/EagleMailClient.java
+++ b/eagle-core/eagle-common/src/main/java/org/apache/eagle/common/mail/EagleMailClient.java
@@ -24,7 +24,6 @@
 import org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-
 import javax.activation.DataHandler;
 import javax.activation.DataSource;
 import javax.activation.FileDataSource;
@@ -38,9 +37,9 @@
 import java.util.Properties;
 
 public class EagleMailClient {
+    
     private static final Logger LOG = LoggerFactory.getLogger(EagleMailClient.class);
     private static final String BASE_PATH = "templates/";
-
     private VelocityEngine velocityEngine;
     private Session session;
 
@@ -53,6 +52,8 @@
             velocityEngine = new VelocityEngine();
             velocityEngine.setProperty(RuntimeConstants.RESOURCE_LOADER, "classpath");
             velocityEngine.setProperty("classpath.resource.loader.class", ClasspathResourceLoader.class.getName());
+            velocityEngine.setProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM_CLASS, org.apache.velocity.runtime.log.Log4JLogChute.class.getName());
+            velocityEngine.setProperty("runtime.log.logsystem.log4j.logger", LOG.getName());
             velocityEngine.init();
 
             config.put("mail.transport.protocol", "smtp");
@@ -60,9 +61,9 @@
                 session = Session.getInstance(config, new Authenticator() {
                     protected PasswordAuthentication getPasswordAuthentication() {
                         return new PasswordAuthentication(
-                            config.getProperty(AlertEmailConstants.CONF_AUTH_USER),
-                            config.getProperty(AlertEmailConstants.CONF_AUTH_PASSWORD)
-                        );
+                                config.getProperty(AlertEmailConstants.CONF_AUTH_USER),
+                                config.getProperty(AlertEmailConstants.CONF_AUTH_PASSWORD)
+                                );
                     }
                 });
             } else {