5 Replies Latest reply on Apr 16, 2004 11:59 AM by Scott Stark

    where to place my logging.Logger.pluginClass

    Ken Hohl Newbie

      I'm attempting to replace the default logger by defining org.jboss.logging.Logger.pluginClass with the value of my class. However, no matter where I place my logging class, JBoss can't find it and resorts to using the NullLoggerPlugin (this is done in Logger.init). Where should I place my class so it can be found?

        • 1. Re: where to place my logging.Logger.pluginClass
          Juha Lindfors Master

          Looks like the init is called when the Logger class is loaded for the first time -- so you may have to force it as early as putting it into the system classpath (can't remember if there's a convenient switch for this in the JBoss start script). Or packaging it inside run.jar should work too. JBOSS_HOME/server/.../lib is most likely way too late.

          Haven't tried this but good luck.

          • 2. Re: where to place my logging.Logger.pluginClass
            Ken Hohl Newbie

            Thanks for replying.

            Unfortunately, I just tried both adding the class to the system classpath and adding it to run.jar and it still can't be found.

            • 3. Re: where to place my logging.Logger.pluginClass
              Scott Stark Master

              Your logger plugin needs to be in a jar in JBOSS_HOME/lib and this needs to be added to the bootstrap classpath by passing in a -L jarname. Here is an example of using custom logger plugin which uses the JDK java.util.logging framework:

              [starksm@banshee9100 bin]$ run.sh -c minimal -L logger.jar
              =========================================================================
              
               JBoss Bootstrap Environment
              
               JBOSS_HOME: C:\cvs\JBoss3.2\jboss-3.2\build\output\jboss-3.2.4RC2
              
               JAVA: /usr/java/j2sdk1.4.2_04/bin/java
              
               JAVA_OPTS: -Dorg.jboss.logging.Logger.pluginClass=logging.MyLoggerPlugin
              -Djava.util.logging.config.file=logging.properties -Dprogram.name=run.sh
              
               CLASSPATH: C:\cvs\JBoss3.2\jboss-3.2\build\output\jboss-3.2.4RC2\bin\run.jar;C:\usr\java\j2sdk1.4.2_04\lib\tools.jar
              
              =========================================================================
              
              java.lang.Exception: Stack trace
               at java.lang.Thread.dumpStack(Thread.java:1064)
               at logging.MyLoggerPlugin.<clinit>(MyLoggerPlugin.java:18)
               at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
               at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
               at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
               at java.lang.reflect.Constructor.newInstance(Constructor.java:274)
               at java.lang.Class.newInstance0(Class.java:308)
               at java.lang.Class.newInstance(Class.java:261)
               at org.jboss.logging.Logger.getDelegatePlugin(Logger.java:312)
               at org.jboss.logging.Logger.<init>(Logger.java:78)
               at org.jboss.logging.Logger.getLogger(Logger.java:291)
               at org.jboss.system.server.ServerImpl.doInit(ServerImpl.java:153)
               at org.jboss.system.server.ServerImpl.init(ServerImpl.java:127)
               at org.jboss.Main.boot(Main.java:139)
               at org.jboss.Main$1.run(Main.java:389)
               at java.lang.Thread.run(Thread.java:534)
              <?xml version="1.0" encoding="windows-1252" standalone="no"?>
              <!DOCTYPE log SYSTEM "logger.dtd">
              <log>
              <record>
               <date>2004-04-14T19:22:54</date>
               <millis>1081995774656</millis>
               <sequence>0</sequence>
               <logger>org.jboss.system.server.Server</logger>
               <level>INFO</level>
               <class>logging.MyLoggerPlugin</class>
               <method>info</method>
               <thread>10</thread>
               <message>Starting JBoss (MX MicroKernel)...</message>
              </record>
              <record>
               <date>2004-04-14T19:22:54</date>
               <millis>1081995774687</millis>
               <sequence>1</sequence>
               <logger>org.jboss.system.server.Server</logger>
               <level>INFO</level>
               <class>logging.MyLoggerPlugin</class>
               <method>info</method>
               <thread>10</thread>
               <message>Release ID: JBoss [WonderLand] 3.2.4RC2 (build: CVSTag=Branch_3_2 date=200404091321)</message>
              </record>
              <record>
               <date>2004-04-14T19:22:54</date>
               <millis>1081995774687</millis>
               <sequence>2</sequence>
               <logger>org.jboss.system.server.Server</logger>
               <level>INFO</level>
               <class>logging.MyLoggerPlugin</class>
               <method>info</method>
               <thread>10</thread>
               <message>Home Dir: C:\cvs\JBoss3.2\jboss-3.2\build\output\jboss-3.2.4RC2</message>
              </record>
              <record>
               <date>2004-04-14T19:22:54</date>
               <millis>1081995774687</millis>
               <sequence>3</sequence>
               <logger>org.jboss.system.server.Server</logger>
               <level>INFO</level>
               <class>logging.MyLoggerPlugin</class>
               <method>info</method>
               <thread>10</thread>
               <message>Home URL: file:/C:/cvs/JBoss3.2/jboss-3.2/build/output/jboss-3.2.4RC2/</message>
              </record>
              <record>
               <date>2004-04-14T19:22:54</date>
               <millis>1081995774703</millis>
               <sequence>4</sequence>
               <logger>org.jboss.system.server.Server</logger>
               <level>INFO</level>
               <class>logging.MyLoggerPlugin</class>
               <method>info</method>
               <thread>10</thread>
               <message>Library URL: file:/C:/cvs/JBoss3.2/jboss-3.2/build/output/jboss-3.2.4RC2/lib/</message>
              </record>
              <record>
               <date>2004-04-14T19:22:54</date>
               <millis>1081995774703</millis>
               <sequence>5</sequence>
               <logger>org.jboss.system.server.Server</logger>
               <level>INFO</level>
               <class>logging.MyLoggerPlugin</class>
               <method>info</method>
               <thread>10</thread>
               <message>Patch URL: null</message>
              </record>
              <record>
               <date>2004-04-14T19:22:54</date>
               <millis>1081995774703</millis>
               <sequence>6</sequence>
               <logger>org.jboss.system.server.Server</logger>
               <level>INFO</level>
               <class>logging.MyLoggerPlugin</class>
               <method>info</method>
               <thread>10</thread>
               <message>Server Name: minimal</message>
              </record>
              <record>
               <date>2004-04-14T19:22:54</date>
               <millis>1081995774718</millis>
               <sequence>7</sequence>
               <logger>org.jboss.system.server.Server</logger>
               <level>INFO</level>
               <class>logging.MyLoggerPlugin</class>
               <method>info</method>
               <thread>10</thread>
               <message>Server Home Dir: C:\cvs\JBoss3.2\jboss-3.2\build\output\jboss-3.2.4RC2\server\minimal</message>
              </record>
              <record>
               <date>2004-04-14T19:22:54</date>
               <millis>1081995774718</millis>
               <sequence>8</sequence>
               <logger>org.jboss.system.server.Server</logger>
               <level>INFO</level>
               <class>logging.MyLoggerPlugin</class>
               <method>info</method>
               <thread>10</thread>
               <message>Server Home URL: file:/C:/cvs/JBoss3.2/jboss-3.2/build/output/jboss-3
              .2.4RC2/server/minimal/</message>
              </record>
              <record>
               <date>2004-04-14T19:22:54</date>
               <millis>1081995774718</millis>
               <sequence>9</sequence>
               <logger>org.jboss.system.server.Server</logger>
               <level>INFO</level>
               <class>logging.MyLoggerPlugin</class>
               <method>info</method>
               <thread>10</thread>
               <message>Server Data Dir: C:\cvs\JBoss3.2\jboss-3.2\build\output\jboss-3.2.4RC2\server\minimal\data</message>
              </record>
              <record>
               <date>2004-04-14T19:22:54</date>
               <millis>1081995774718</millis>
               <sequence>10</sequence>
               <logger>org.jboss.system.server.Server</logger>
               <level>INFO</level>
               <class>logging.MyLoggerPlugin</class>
               <method>info</method>
               <thread>10</thread>
               <message>Server Temp Dir: C:\cvs\JBoss3.2\jboss-3.2\build\output\jboss-3.2.4RC2\server\minimal\tmp</message>
              </record>
              <record>
               <date>2004-04-14T19:22:54</date>
               <millis>1081995774734</millis>
               <sequence>11</sequence>
               <logger>org.jboss.system.server.Server</logger>
               <level>INFO</level>
               <class>logging.MyLoggerPlugin</class>
               <method>info</method>
               <thread>10</thread>
               <message>Server Config URL: file:/C:/cvs/JBoss3.2/jboss-3.2/build/output/jboss-3.2.4RC2/server/minimal/conf/</message>
              </record>
              <record>
               <date>2004-04-14T19:22:54</date>
               <millis>1081995774734</millis>
               <sequence>12</sequence>
               <logger>org.jboss.system.server.Server</logger>
               <level>INFO</level>
               <class>logging.MyLoggerPlugin</class>
               <method>info</method>
               <thread>10</thread>
               <message>Server Library URL: file:/C:/cvs/JBoss3.2/jboss-3.2/build/output/jboss-3.2.4RC2/server/minimal/lib/</message>
              </record>
              <record>
               <date>2004-04-14T19:22:54</date>
               <millis>1081995774734</millis>
               <sequence>13</sequence>
               <logger>org.jboss.system.server.Server</logger>
               <level>INFO</level>
               <class>logging.MyLoggerPlugin</class>
               <method>info</method>
               <thread>10</thread>
               <message>Root Deployment Filename: jboss-service.xml</message>
              </record>
              <record>
               <date>2004-04-14T19:22:54</date>
               <millis>1081995774750</millis>
               <sequence>14</sequence>
               <logger>org.jboss.system.server.Server</logger>
               <level>INFO</level>
               <class>logging.MyLoggerPlugin</class>
               <method>info</method>
               <thread>10</thread>
               <message>Starting General Purpose Architecture (GPA)...</message>
              </record>
              <record>
               <date>2004-04-14T19:22:58</date>
               <millis>1081995778640</millis>
               <sequence>15</sequence>
               <logger>org.jboss.system.server.ServerInfo</logger>
               <level>INFO</level>
               <class>logging.MyLoggerPlugin</class>
               <method>info</method>
               <thread>10</thread>bin]$
               <message>Java version: 1.4.2_04,Sun Microsystems Inc.</message>
              </record>
              <record>
               <date>2004-04-14T19:22:58</date>
               <millis>1081995778640</millis>
               <sequence>16</sequence>
               <logger>org.jboss.system.server.ServerInfo</logger>
               <level>INFO</level>
               <class>logging.MyLoggerPlugin</class>
               <method>info</method>
               <thread>10</thread>
               <message>Java VM: Java HotSpot(TM) Client VM 1.4.2_04-b05,Sun Microsystems Inc
              .</message>
              </record>
              <record>
               <date>2004-04-14T19:22:58</date>
               <millis>1081995778640</millis>
               <sequence>17</sequence>
               <logger>org.jboss.system.server.ServerInfo</logger>
               <level>INFO</level>
               <class>logging.MyLoggerPlugin</class>
               <method>info</method>
               <thread>10</thread>
               <message>OS-System: Windows XP 5.1,x86</message>
              </record>
              <record>
               <date>2004-04-14T19:22:58</date>
               <millis>1081995778921</millis>
               <sequence>18</sequence>
               <logger>org.jboss.system.server.Server</logger>
               <level>INFO</level>
               <class>logging.MyLoggerPlugin</class>
               <method>info</method>
               <thread>10</thread>
               <message>Core system initialized</message>
              </record>
              <record>
               <date>2004-04-14T19:22:59</date>
               <millis>1081995779625</millis>
               <sequence>19</sequence>
               <logger>org.jboss.logging.Log4jService$URLWatchTimerTask</logger>
               <level>INFO</level>
               <class>logging.MyLoggerPlugin</class>
               <method>info</method>
               <thread>10</thread>
               <message>Configuring from URL: resource:log4j.xml</message>
              </record>
              19:22:59,968 INFO [NamingService] Started jnpPort=1099, rmiPort=0, backlog=50,
              bindAddress=null, Client SocketFactory=null, Server SocketFactory=null
              <record>
               <date>2004-04-14T19:23:00</date>
               <millis>1081995780015</millis>
               <sequence>20</sequence>
               <logger>org.jboss.system.server.Server</logger>
               <level>INFO</level>
               <class>logging.MyLoggerPlugin</class>
               <method>info</method>
               <thread>10</thread>
               <message>JBoss (MX MicroKernel) [3.2.4RC2 (build: CVSTag=Branch_3_2 date=200404091321)] Started in 5s:265ms</message>
              </record>
              



              • 4. Re: where to place my logging.Logger.pluginClass
                Ken Hohl Newbie

                Thanks for replying. I had given up on this functionality until you did. Following your directions does allow JBoss to find my plugin class. However, JBoss 3.2.3 doesn't start because some code assumes no replacement of the standard logger. See stack trace below generated during startup:

                This is the line at the top of the stack:

                PrintWriter logWriter = new LoggerWriter(((org.jboss.logging.Log4jLoggerPlugin)log.getLoggerPlugin ()).getLogger());



                13:37:33,175 ERROR [TxConnectionManager] Starting failed
                java.lang.ClassCastException: com.apropos.api.jboss.JBossLoggerPlugin
                at org.jboss.resource.connectionmanager.BaseConnectionManager2.startService(BaseConnectionManager2.java:342)
                at org.jboss.resource.connectionmanager.TxConnectionManager.startService(TxConnectionManager.java:284)
                at org.jboss.system.ServiceMBeanSupport.start(ServiceMBeanSupport.java:192)
                at java.lang.reflect.Method.invoke(Native Method)
                at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284)
                at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:546)
                at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:976)
                at $Proxy14.start(Unknown Source)
                at org.jboss.system.ServiceController.start(ServiceController.java:394)
                at org.jboss.system.ServiceController.start(ServiceController.java:411)
                at java.lang.reflect.Method.invoke(Native Method)
                at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284)
                at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:546)
                at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177)
                at $Proxy4.start(Unknown Source)
                at org.jboss.deployment.SARDeployer.start(SARDeployer.java:226)
                at org.jboss.deployment.MainDeployer.start(MainDeployer.java:832)
                at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:642)
                at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:605)
                at java.lang.reflect.Method.invoke(Native Method)
                at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284)
                at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:546)
                at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177)
                at $Proxy6.deploy(Unknown Source)
                at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java:302)
                at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:476)
                at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.doScan(AbstractDeploymentScanner.java:201)
                at org.jboss.deployment.scanner.AbstractDeploymentScanner.startService(AbstractDeploymentScanner.java:274)
                at org.jboss.system.ServiceMBeanSupport.start(ServiceMBeanSupport.java:192)
                at java.lang.reflect.Method.invoke(Native Method)
                at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284)
                at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:546)
                at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:976)
                at $Proxy0.start(Unknown Source)
                at org.jboss.system.ServiceController.start(ServiceController.java:394)
                at java.lang.reflect.Method.invoke(Native Method)
                at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284)
                at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:546)
                at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177)
                at $Proxy4.start(Unknown Source)
                at org.jboss.deployment.SARDeployer.start(SARDeployer.java:226)
                at org.jboss.deployment.MainDeployer.start(MainDeployer.java:832)
                at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:642)
                at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:605)
                at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:589)
                at java.lang.reflect.Method.invoke(Native Method)
                at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284)
                at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:546)
                at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177)
                at $Proxy5.deploy(Unknown Source)
                at org.jboss.system.server.ServerImpl.doStart(ServerImpl.java:384)
                at org.jboss.system.server.ServerImpl.start(ServerImpl.java:291)
                at org.jboss.Main.boot(Main.java:150)
                at org.jboss.Main$1.run(Main.java:395)
                at java.lang.Thread.run(Thread.java:479)