9 Replies Latest reply on Sep 22, 2010 1:50 PM by Peter Johnson

    Problem on Log4j: How to include custom <filter/> into JBoss (log4j.xml)?

    Kevin Ng Newbie
      <appender name="TRANS" class="org.apache.log4j.DailyRollingFileAppender">
                      <filter class="log4j.TransFilter"/>
          </appender>
      <appender name="TRANS" class="org.apache.log4j.DailyRollingFileAppender">
              <param name="File" value="C:/myLogFile.log"/>
              <param name="DatePattern" value="'.'yyyy-MM"/>
              <param name="Append" value="true"/>
              <layout class="org.apache.log4j.PatternLayout">
                  <param name="ConversionPattern" value="%m%n"/>
              </layout>
              <filter class="TransFilter"/>
      </appender>
      
      <root>
            <appender-ref ref="CONSOLE"/>
            <appender-ref ref="FILE"/>
           <appender-ref ref="TRANS"/>
      </root>
      

       

      TransFilter is a custom filter that I have created, a .java file.
      This run fine as Java Application.

       

      When I tried to convert into JBoss log4j and error occur.

       

      File located: ../server/default/conf/log4j.xml

      <appender name="TRANS" class="org.apache.log4j.DailyRollingFileAppender">
              <param name="File" value="${jboss.server.home.dir}/log/transaction.log"/>
              <param name="DatePattern" value="'.'yyyy-MM"/>
              <param name="Append" value="true"/>
              <layout class="org.apache.log4j.PatternLayout">
                  <param name="ConversionPattern" value="%m%n"/>
              </layout>
              <filter class="log4j.TransFilter"/>
          </appender>
      
      <root>
            <appender-ref ref="CONSOLE"/>
            <appender-ref ref="FILE"/>
           <appender-ref ref="TRANS"/>
      </root>
      

       

      Error occurred at server log file.

      log4j:ERROR Could not instantiate class [log4j.TransFilter].
      java.lang.ClassNotFoundException: log4j.TransFilter
              at java.net.URLClassLoader$1.run(URLClassLoader.java:199)
              at java.security.AccessController.doPrivileged(Native Method)
              at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
              at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
              at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
              at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
              at java.lang.Class.forName0(Native Method)
              at java.lang.Class.forName(Class.java:141)
              at org.apache.log4j.helpers.Loader.loadClass(Loader.java:160)
              at org.apache.log4j.helpers.OptionConverter.instantiateByClassName(Optio
      nConverter.java:309)
              at org.apache.log4j.xml.DOMConfigurator.parseFilters(DOMConfigurator.jav
      a:269)
              at org.apache.log4j.xml.DOMConfigurator.parseAppender(DOMConfigurator.ja
      va:190)
              at org.apache.log4j.xml.DOMConfigurator.findAppenderByName(DOMConfigurat
      or.java:140)
              at org.apache.log4j.xml.DOMConfigurator.findAppenderByReference(DOMConfi
      gurator.java:153)
              at org.apache.log4j.xml.DOMConfigurator.parseChildrenOfLoggerElement(DOM
      Configurator.java:415)
              at org.apache.log4j.xml.DOMConfigurator.parseRoot(DOMConfigurator.java:3
      84)
              at org.apache.log4j.xml.DOMConfigurator.parse(DOMConfigurator.java:783)
              at org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java
      :666)
              at org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java
      :616)
              at org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java
      :602)
              at org.apache.log4j.xml.DOMConfigurator.configure(DOMConfigurator.java:6
      97)
              at org.jboss.logging.Log4jService$URLWatchTimerTask.reconfigure(Log4jSer
      vice.java:624)
              at org.jboss.logging.Log4jService$URLWatchTimerTask.run(Log4jService.jav
      a:563)
              at org.jboss.logging.Log4jService.setup(Log4jService.java:450)
              at org.jboss.logging.Log4jService.createService(Log4jService.java:466)
              at org.jboss.system.ServiceMBeanSupport.jbossInternalCreate(ServiceMBean
      Support.java:237)
              at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMB
      eanSupport.java:219)
              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
      java:39)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
      sorImpl.java:25)
              at java.lang.reflect.Method.invoke(Method.java:324)
              at org.jboss.mx.server.ReflectedDispatcher.dispatch(ReflectedDispatcher.
      java:60)
              at org.jboss.mx.server.Invocation.dispatch(Invocation.java:61)
              at org.jboss.mx.server.Invocation.dispatch(Invocation.java:53)
              at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
              at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.
      java:185)
              at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:473)
              at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceControl
      ler.java:837)
              at $Proxy0.create(Unknown Source)
              at org.jboss.system.ServiceController.create(ServiceController.java:283)
      
              at org.jboss.system.ServiceController.create(ServiceController.java:216)
      
              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
      java:39)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
      sorImpl.java:25)
              at java.lang.reflect.Method.invoke(Method.java:324)
              at org.jboss.mx.server.ReflectedDispatcher.dispatch(ReflectedDispatcher.
      java:60)
              at org.jboss.mx.server.Invocation.dispatch(Invocation.java:61)
              at org.jboss.mx.server.Invocation.dispatch(Invocation.java:53)
              at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
              at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.
      java:185)
              at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:473)
              at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:176)
              at $Proxy4.create(Unknown Source)
              at org.jboss.deployment.SARDeployer.create(SARDeployer.java:213)
              at org.jboss.deployment.MainDeployer.create(MainDeployer.java:790)
              at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:644)
              at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:608)
              at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:592)
              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
      java:39)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
      sorImpl.java:25)
              at java.lang.reflect.Method.invoke(Method.java:324)
              at org.jboss.mx.server.ReflectedDispatcher.dispatch(ReflectedDispatcher.
      java:60)
              at org.jboss.mx.server.Invocation.dispatch(Invocation.java:61)
              at org.jboss.mx.server.Invocation.dispatch(Invocation.java:53)
              at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
              at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.
      java:185)
              at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:473)
              at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:176)
              at $Proxy5.deploy(Unknown Source)
              at org.jboss.system.server.ServerImpl.doStart(ServerImpl.java:407)
              at org.jboss.system.server.ServerImpl.start(ServerImpl.java:311)
              at org.jboss.Main.boot(Main.java:145)
              at org.jboss.Main$1.run(Main.java:399)
              at java.lang.Thread.run(Thread.java:534)