1 Reply Latest reply on Jan 29, 2013 6:22 PM by tcunning

    Logging into Database instead of file

    ashok.rajendran

      Hi,

       

      I would like to persist the logs into database instead of file. I have done some of the changes based on my finding in jboss forum. but I couldn't achieve to write logs into database (oracle).  The changes which I have done are,

       

      Steps 1: Created the table into database (oracle) using below query

      CREATE TABLE LOGS (
                                                      logdate     Date,
                                                      priority    VARCHAR2(10),
                                                      category    VARCHAR2(35),
                                                      thread      VARCHAR2(20),
                                                      message     VARCHAR2(100))

       

       

      Step 2:  Added the below lines into jboss-log4j.xml

       

                    <appender name="jdbcAppender" class="org.apache.log4j.jdbc.JDBCAppender">

                     <param name="URL" value="jdbc:oracle:thin:localhost:1521:xe" />

                     <param name="Driver" value="oracle.jdbc.driver.OracleDriver" />

                    <param name="User" value="esb" />

                    <param name="Password" value="esb1234" />

                    <param name="Sql" value="INSERT INTO LOGS VALUES('%d','%-5p','%c','%t','%m')" /> 

                 </appender>

       

                  <category name="test.dblogger">

                     <priority value="INFO" />

                    <appender-ref ref="jdbcAppender"/>

                    <appender-ref ref="fileAppender"/>

                  </category>

       

       

      From the step 2, I am trying to log in both file and db, I could able to see the logs only in file but not in db. Anybody can guide me to resolve this issue..

       

       

      Thanks and Regards,

      Ashok

        • 1. Re: Logging into Database instead of file
          tcunning

          This isn't really an ESB question, but maybe the "Sql" element should be "sql", and the "User" and "Password" and "Driver" params should be "user", "password", and "driver" respectively?     Maybe you haven't hit the buffer also and should force a whole bunch of logging information so that you make sure you hit the buffer for jdbc write?