<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>Answers to: Log Mail with Log4J SMTP Appender doesn't work</title><link>https://answers.axonivy.com/questions/3601/log-mail-with-log4j-smtp-appender-doesn-t-work</link><description>&lt;p&gt;Hello,
i want Axon Ivy to send an Email when there is an error so i added this code to "log4jconfig.xml":&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&amp;lt; appender name="EmailAppender" class="org.apache.log4j.net.SMTPAppender"&amp;gt;
        &amp;lt; param name="BufferSize" value="512" / &amp;gt;
        &amp;lt; param name="SMTPHost" value="smtp.gmail.com" / &amp;gt; 
        &amp;lt; param name="SMTPProtocol" value="smtps" / &amp;gt;
        &amp;lt; param name="SMTPPort" value="465" / &amp;gt;
        &amp;lt; param name="SMTPUsername" value=" *** " / &amp;gt;
        &amp;lt; param name="SMTPPassword" value=" *** " / &amp;gt;
        &amp;lt; param name="From" value=" *** " / &amp;gt;
        &amp;lt; param name="To" value=" *** " / &amp;gt;
        &amp;lt; param name="Subject" value="Testing Log4j Mail Notification" / &amp;gt;
        &amp;lt; layout class="org.apache.log4j.PatternLayout"&amp;gt;
            &amp;lt; param name="ConversionPattern" value="%-7p %d [%t] %c %x - %m%n" / &amp;gt;
        &amp;lt; /layout &amp;gt;
    &amp;lt; /appender &amp;gt;

  &amp;lt; root &amp;gt; 
    &amp;lt; level value ="WARN" / &amp;gt; 
    &amp;lt; appender-ref ref="FileLog"/ &amp;gt; 
    &amp;lt; appender-ref ref="EmailAppender"/ &amp;gt;
    &amp;lt; appender-ref ref="ConsoleAppender"/ &amp;gt;    
    &amp;lt; /root &amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The FileLog works but i dont receive the email.
When i change the order to this:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&amp;lt; appender-ref ref="EmailAppender"/ &amp;gt;
&amp;lt; appender-ref ref="FileLog"/ &amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;then the FileLog and the MailAppender doesn't work. &lt;br&gt;
When i use the same code in an Eclipse Java Project it works and i get the email.  &lt;/p&gt;
&lt;p&gt;What should i do?&lt;/p&gt;
&lt;p&gt;Edit: Do i have to add mail.jar and activation.jar to my build path in Axon Ivy? In Eclipse i added them to lib and it worked but i don't know how to integrate them to Axon Ivy.&lt;/p&gt;
&lt;p&gt;Edit2: With Log4j debug=true i get this Error in my logfile:  &lt;br&gt;
2019-01-22 16:21:32.230 ERROR [ch.ivyteam.log.LoggerFactory] [main] [] 
  Log4j: Could not configure
    java.lang.NoClassDefFoundError: javax/mail/internet/AddressException
        at java.lang.Class.getDeclaredConstructors0(Native Method)
        at java.lang.Class.privateGetDeclaredConstructors(Class.java:2671)
        at java.lang.Class.getConstructor0(Class.java:3075)
        at java.lang.Class.newInstance(Class.java:412)
        at org.apache.log4j.xml.DOMConfigurator.parseAppender(DOMConfigurator.java:247)
        at org.apache.log4j.xml.DOMConfigurator.findAppenderByName(DOMConfigurator.java:176)   &lt;br&gt;
        ...&lt;/p&gt;</description><atom:link href="https://answers.axonivy.com/questions/3601/log-mail-with-log4j-smtp-appender-doesn-t-work" rel="self"></atom:link><language>en</language><lastBuildDate>Wed, 20 Mar 2019 05:40:08 -0400</lastBuildDate><item><title>Answer by Reto Weiss</title><link>https://answers.axonivy.com/questions/3601/log-mail-with-log4j-smtp-appender-doesn-t-work/3743</link><description>&lt;p&gt;You can try the following:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Open the file /system/plugins/ch.ivyteam.util_*.jar with a ZIP program and extract the file /lib/mvn/javax.mail-1.5.6.jar&lt;/li&gt;
&lt;li&gt;Copy the extracted file to the directory /jre/lib/ext&lt;/li&gt;
&lt;li&gt;Restart the engine&lt;/li&gt;
&lt;/ol&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Reto Weiss</dc:creator><pubDate>Wed, 20 Mar 2019 05:40:08 -0400</pubDate><guid>https://answers.axonivy.com/questions/3601/log-mail-with-log4j-smtp-appender-doesn-t-work/3743</guid></item><item><title>Comment by karstenk on Reguel Wermelinger's answer</title><link>https://answers.axonivy.com/questions/3601/log-mail-with-log4j-smtp-appender-doesn-t-work#3656</link><description>&lt;p&gt;I changed the File in Axon Ivy\plugins\ch.ivyteam.lib.util_7.2.0.201810151000\META-INF\MANIFEST.MF 
The File looks ends like this: 
...
Created-By: Apache Maven 3.5.2
Build-Jdk: 1.8.0_151
Eclipse-BundleShape: dir
Eclipse-RegisterBuddy: commons.lib&lt;/p&gt;
&lt;p&gt;I still get the same error.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">karstenk</dc:creator><pubDate>Tue, 05 Feb 2019 05:21:36 -0500</pubDate><guid>https://answers.axonivy.com/questions/3601/log-mail-with-log4j-smtp-appender-doesn-t-work#3656</guid></item><item><title>Comment by Reguel Wermelinger on Reguel Wermelinger's answer</title><link>https://answers.axonivy.com/questions/3601/log-mail-with-log4j-smtp-appender-doesn-t-work#3648</link><description>&lt;p&gt;Ok thanks for the version info.
My screenshot should just serves as an example on what to write into the Manifest.MF (and focuses to 7.0 users). But the procedure for 7.2.1 is different:
Open the &lt;code&gt;system/plugins/ch.ivyteam.lib.util_7.2.1-XYZ/META-INF/MANIFEST.MF&lt;/code&gt;. Add the line marked in my screenshot.
Run the engine again and see whether the NoClassDefFound errors are gone.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Reguel Wermelinger</dc:creator><pubDate>Wed, 30 Jan 2019 02:44:47 -0500</pubDate><guid>https://answers.axonivy.com/questions/3601/log-mail-with-log4j-smtp-appender-doesn-t-work#3648</guid></item><item><title>Comment by karstenk on Reguel Wermelinger's answer</title><link>https://answers.axonivy.com/questions/3601/log-mail-with-log4j-smtp-appender-doesn-t-work#3647</link><description>&lt;p&gt;I have Version 7.2.1.
I don't have the folder util in my project explorer like in the screenshot.  And when I open the file with the Plugins View, I can't edit the Manifest.mf.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">karstenk</dc:creator><pubDate>Tue, 29 Jan 2019 14:58:46 -0500</pubDate><guid>https://answers.axonivy.com/questions/3601/log-mail-with-log4j-smtp-appender-doesn-t-work#3647</guid></item><item><title>Comment by Reguel Wermelinger on Reguel Wermelinger's answer</title><link>https://answers.axonivy.com/questions/3601/log-mail-with-log4j-smtp-appender-doesn-t-work#3642</link><description>&lt;p&gt;Ok I see. The access from the &lt;code&gt;STMPAppender&lt;/code&gt; to &lt;code&gt;javax.mail.internet.AddressException&lt;/code&gt; is blocked by the default ivy bundle configuration.
You could fix it with a work-around: open the &lt;code&gt;plugins/ch.ivyteam.util_XYZ.jar&lt;/code&gt; and add an additional header to to the &lt;code&gt;META-INF/Manifest.MF&lt;/code&gt; within it.
&lt;code&gt;Eclipse-RegisterBuddy: commons.lib&lt;/code&gt;
If you can need a bulletproof solution please share the Designer version which you are using.&lt;/p&gt;
&lt;p&gt;&lt;img src="https://answers.axonivy.com/upfiles/util-asBuddyOfCommons.png" width="600"&gt;&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Reguel Wermelinger</dc:creator><pubDate>Tue, 29 Jan 2019 03:07:52 -0500</pubDate><guid>https://answers.axonivy.com/questions/3601/log-mail-with-log4j-smtp-appender-doesn-t-work#3642</guid></item><item><title>Comment by karstenk on Reguel Wermelinger's answer</title><link>https://answers.axonivy.com/questions/3601/log-mail-with-log4j-smtp-appender-doesn-t-work#3637</link><description>&lt;p&gt;The SMTP Appender i want to use is a default Appender from Log4j (like the Console Appender). I don't want to build a custom Appender. Is it necessary to build a custom Appender to use the SMTP Appender?&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">karstenk</dc:creator><pubDate>Tue, 22 Jan 2019 08:55:09 -0500</pubDate><guid>https://answers.axonivy.com/questions/3601/log-mail-with-log4j-smtp-appender-doesn-t-work#3637</guid></item><item><title>Answer by Reguel Wermelinger</title><link>https://answers.axonivy.com/questions/3601/log-mail-with-log4j-smtp-appender-doesn-t-work/3632</link><description>&lt;p&gt;The log appender must be made compatible with our OSGi java runtime environment. &lt;/p&gt;
&lt;p&gt;This means that you have to enrich the JAR that supplies the appender with dependencies to our log infrastructure and register it as buddy of our &lt;code&gt;commons.lib&lt;/code&gt; bundle.&lt;/p&gt;
&lt;p&gt;A full blown example is accessible here: &lt;a href="https://github.com/ivy-samples/ivy-extension-demos/tree/master/CustomLogAppender"&gt;https://github.com/ivy-samples/ivy-extension-demos/tree/master/CustomLogAppender&lt;/a&gt;&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Reguel Wermelinger</dc:creator><pubDate>Tue, 22 Jan 2019 04:37:35 -0500</pubDate><guid>https://answers.axonivy.com/questions/3601/log-mail-with-log4j-smtp-appender-doesn-t-work/3632</guid></item><item><title>Comment by karstenk on karstenk's question</title><link>https://answers.axonivy.com/questions/3601/log-mail-with-log4j-smtp-appender-doesn-t-work#3607</link><description>&lt;p&gt;Thanks for your answer but all Appenders are together.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">karstenk</dc:creator><pubDate>Fri, 11 Jan 2019 05:49:06 -0500</pubDate><guid>https://answers.axonivy.com/questions/3601/log-mail-with-log4j-smtp-appender-doesn-t-work#3607</guid></item><item><title>Comment by Christian Strebel on karstenk's question</title><link>https://answers.axonivy.com/questions/3601/log-mail-with-log4j-smtp-appender-doesn-t-work#3603</link><description>&lt;p&gt;May be you defined the appender at the wrong location in the log4jconfig.xml? All Appenders must be together!&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Christian Strebel</dc:creator><pubDate>Tue, 08 Jan 2019 10:25:44 -0500</pubDate><guid>https://answers.axonivy.com/questions/3601/log-mail-with-log4j-smtp-appender-doesn-t-work#3603</guid></item></channel></rss>