4 Replies Latest reply on Jun 30, 2011 4:17 AM by achill mantzios

    jboss-logging.xml and JDBCAppender in jboss-6.0.0.Final

    achill mantzios Newbie

      Hello,

      i am in the process of migration from jboss-4.2.3 to jboss-6.0.0 and i have been struggling with this problem. In the old installation i was using org.apache.log4j.jdbcplus.JDBCAppender from http://www.dankomannhaupt.de/projects/index.html which performed (in the sense of working) better than the standard JDBCAppender from apache's log4j's JDBCAppender. All this was done in the old format  jboss-log4j.xml .

       

      Now i see things have moved over to jboss-logging.xml which seems to have a different format. I have successfully managed to do some basic configuration in this file (like set up my basic file-logging services), but have failed miserably in any attempt to set up either the enhanced org.apache.log4j.jdbcplus.JDBCAppender or the standard (but discouraged) org.apache.log4j.jdbc.JDBCAppender.

       

      I have setup all relevant jars in JBOSS_BOOT_CLASSPATH in order to avoid classpath problems.

       

      I tried with org.apache.log4j.jdbcplus.JDBCAppender :

       

      <log4j-appender name="DYNAJDBC" class="org.apache.log4j.jdbcplus.JDBCAppender">
            <error-manager>
               <only-once/>
            </error-manager>
      
            <properties>
               <property name="dbclass">org.postgresql.Driver</property>
               <property name="url">jdbc:postgresql://localhost/dynacom</property>
               <property name="username">postgres</property>
               <property name="password">pazzword</property>
               <property name="sql">insert into logging(logtime,category,username,action) values('@TIMESTAMP@','@CAT@',substring('@MSG@'
      from 1 for position(' ' in '@MSG@')-1),'@MSG@')</property>
               <property name="quoteReplace">true</property>
            </properties>
      
            <formatter>
               <pattern-formatter pattern="%d{HH:mm:ss,SSS} %-5p [%c] %s%E%n"/>
            </formatter>
      
         </log4j-appender>
      

       

      In the above case i get no error messages at all, but the thing just do not work. I touch jboss-logging.xml, i get

      16:35:42,670 INFO  [service] Restored bootstrap log handlers

      16:35:42,675 INFO  [service] Removing bootstrap log handlers

      but nothing from the db side, no connection, no error, and unfortunately no logging

       

       

      Then I tried with the traditional appender org.apache.log4j.jdbc.JDBCAppender :

       

      <log4j-appender name="DYNAJDBC" class="org.apache.log4j.jdbc.JDBCAppender">
            <error-manager>
               <only-once/>
            </error-manager>
            <properties>
               <property name="driver">org.postgresql.Driver</property>
               <property name="URL">jdbc:postgresql://localhost/dynacom</property>
               <property name="user">postgres</property>
               <property name="password">pazzword</property>
               <property name="sql">insert into logging values(now(),'some cat','some user','some action')</property>
            </properties>
            <formatter>
               <pattern-formatter pattern="%d{HH:mm:ss,SSS} %-5p [%c] %s%E%n"/>
            </formatter>
         </log4j-appender>
      

       

      In this case, when the server is started i get no errors, no exceptions, but i get no database activity as well. When i re-touch jboss-logging.xml , then i get

       

      16:42:53,726 ERROR [STDERR] java.lang.NullPointerException

      16:42:53,727 ERROR [STDERR]     at java.lang.Class.forName0(Native Method)

      16:42:53,727 ERROR [STDERR]     at java.lang.Class.forName(Class.java:186)

      16:42:53,727 ERROR [STDERR]     at org.apache.log4j.jdbc.JDBCAppender.setDriver(JDBCAppender.java:351)

      16:42:53,727 ERROR [STDERR]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

      ................

       

      Is there anyone who have successfully used JDBC logging with jboss 6?