3 Replies Latest reply on Jun 18, 2003 10:53 AM by Darran Lofthouse

    Log JDBC calls

    Mads Pultz Newbie


      I debugging my CMP beans and a usefull tool would be a log of all container issued JDBC calls. Can this be done? Through log4j? If so how is it done, can you give an example?


        • 1. Re: Log JDBC calls
          Grzegorz Stelmaszek Newbie

          All DB calls are logged on a debug level by default, so you can try to enable logging on debug (default is on info) in log4j config file (server/*/conf/log4j.xml).

          Also please note that logging on debug level kills performance and must not be used on a production system.

          • 2. Re: Log JDBC calls
            Mark Frost Newbie

            If you want to turn on just SQL logging you can do the following in log4j.xml:

            1. Comment out the Threshold node of the CONSOLE appender - otherwise DEBUG events will never be displayed:

            2. Set the root priority to INFO so that we don't create loads of output:

            <appender-ref ref="CONSOLE"/>
            <appender-ref ref="FILE"/>

            3. Finally create a category based upon cmp.jdbc

            4. Save the file - after 1 minute the log4j xml is reparsed and hey presto JDBC log messages appear e.g:

            14:33:27,834 DEBUG [findByPrimaryKey] Executing SQL: SELECT Company_Id FROM COMPANY_XML WHERE Company_Id=?


            • 3. Re: Log JDBC calls
              Darran Lofthouse Master

              Just tried your instructions and they work perfectly.

              Would it be worth adding this to the CMP documentation?