1 Reply Latest reply on Sep 27, 2017 6:08 AM by Tomaz Cerar

    Custom Logger for SMTP log handler with EvaluatorClass property not working in WildFly10

    Mayank Gupta Newbie

      I am configuring the custom handler for SMTP as follows:

      <custom-handler name="SMTP" module="org.apache.log4j" class="org.apache.log4j.net.SMTPAppender">

         <level name="ERROR"/>

                      <formatter>

                          <named-formatter name="PATTERN"/>

                      </formatter>

      <properties>

      <property name="evaluatorClass" value="com.myproject.utility.merlinlog4j.EmailThrottle"/>

      <property name="to" value="${to.email}"/>

      <property name="from" value="${from.email}"/>

      <property name="subject" value="${email.subject}"/>

      <property name="SMTPHost" value="${smtp.host}"/>

      <property name="bufferSize" value="10"/>

      </properties>

      </custom-handler>

       

      On starting the server, I get the following error:

      ERROR Could not instantiate class [com.myproject.utility.merlinlog4j.EmailThrottle]

      java.lang.ClassNotFoundException: com.myproject.utility.merlinlog4j.EmailThrottle from [Module "org.jboss.log4j.logmanager:main" from local module loader @1068e947 (finder: local module finder @7dc222ae (roots: E:\wildfly-10.1.0.Final\modules,E:\wildfly-10.1.0.Final\modules\system\layers\base))]

              at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:198)

              at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:363)

              at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:351)

              at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:93)

              at java.lang.Class.forName0(Native Method)

              at java.lang.Class.forName(Class.java:264)

              at org.apache.log4j.helpers.Loader.loadClass(Loader.java:198)

              at org.apache.log4j.helpers.OptionConverter.instantiateByClassName(OptionConverter.java:326)

              at org.apache.log4j.net.SMTPAppender.setEvaluatorClass(SMTPAppender.java:548)

              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

              at java.lang.reflect.Method.invoke(Method.java:498)

              at org.jboss.logmanager.config.AbstractPropertyConfiguration$1.applyPostCreate(AbstractPropertyConfiguration.java:216)

              at org.jboss.logmanager.config.AbstractPropertyConfiguration$1.applyPostCreate(AbstractPropertyConfiguration.java:196)

              at org.jboss.logmanager.config.LogContextConfigurationImpl.doApplyPostCreate(LogContextConfigurationImpl.java:312)

              at org.jboss.logmanager.config.LogContextConfigurationImpl.doPrepare(LogContextConfigurationImpl.java:344)

              at org.jboss.logmanager.config.LogContextConfigurationImpl.prepare(LogContextConfigurationImpl.java:288)

              at org.jboss.logmanager.config.LogContextConfigurationImpl.commit(LogContextConfigurationImpl.java:297)

              at org.jboss.logmanager.PropertyConfigurator.configure(PropertyConfigurator.java:546)

              at org.jboss.logmanager.PropertyConfigurator.configure(PropertyConfigurator.java:97)

              at org.jboss.logmanager.LogManager.readConfiguration(LogManager.java:514)

              at org.jboss.logmanager.LogManager.readConfiguration(LogManager.java:476)

              at java.util.logging.LogManager$3.run(LogManager.java:399)

              at java.util.logging.LogManager$3.run(LogManager.java:396)

              at java.security.AccessController.doPrivileged(Native Method)

              at java.util.logging.LogManager.readPrimordialConfiguration(LogManager.java:396)

              at java.util.logging.LogManager.access$800(LogManager.java:145)

              at java.util.logging.LogManager$2.run(LogManager.java:345)

              at java.security.AccessController.doPrivileged(Native Method)

              at java.util.logging.LogManager.ensureLogManagerInitialized(LogManager.java:338)

              at java.util.logging.LogManager.getLogManager(LogManager.java:378)

              at org.jboss.modules.Main.main(Main.java:480)

       

      As I can see that it is searching for this class file in module defined in the module section of custom-handler. However this file is actually present in my deployment ear file and not within any of the module files as it is not the third party jar or dependent module.

       

      What configuration changes I would need to get this working?