2 Replies Latest reply on Nov 10, 2010 11:55 AM by Leo van den berg

    Loggin into database

    Philippe Aubertin Newbie

      Hi everybody!
      Is there a way to log directly into database?
      I tried to deal with /jboss/{default}/conf/jboss-log4j.xml, but I can't make it work.

      Is there any solutions?

      What I have tried... I getting no errors but no logs too...

      Jboss 5 et JDK 5 and SEAM 2.2

       <appender name="JDBC" class="org.apache.log4j.jdbc.JDBCAppender">
                   <param name="driver" value="com.mysql.jdbc.Driver"/>
                   <param name="URL" value="jdbc:mysql://localhost:3306/emploi_log"/>
                   <param name="user" value="root"/>
                   <param name="password" value=""/>
                  <layout class="org.apache.log4j.PatternLayout">     
                <param name="ConversionPattern"  value="INSERT INTO LOGS VALUES('%x','%d','%C','%p','%m');"/>

      Best regards.

      Aubertin Philippe

        • 1. Re: Loggin into database
          Philippe Aubertin Newbie

          I tried differents things but I can't make it work...

          I still need help...

          Best regards.

          • 2. Re: Loggin into database
            Leo van den berg Master


            I've seen examples with the jdbcplus driver from apache. With this example in mind, I think you're putting the SQL at the wrong param-element. Try using a name attribute sql instead. Furthermore URL shouldn't be written with capitals.

            I am not using this way of logging. I've created a specific log class and send every log to an log-processor which is called with an async-event. after persisting it logs with the default logger (depending on the log-level). This doesn't work for system specific logs (such as Hibernate) but gives me better control over the persistency proces. In this way I give preference to database access for the application and store the logs with a lower priority.