Version 7

    View the SQL generated by JBoss CMP


    To view the SQL generated by JBoss CMP, add the following code to log4j.xml


    <appender name="CMP" class="org.jboss.logging.appender.RollingFileAppender">
        <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"></errorHandler>
        <param name="File" value="${jboss.server.log.dir}/cmp.log"/>
        <param name="Append" value="false"/>
        <param name="MaxFileSize" value="500KB"/>
        <param name="MaxBackupIndex" value="1"/>
        <layout class="org.apache.log4j.PatternLayout">
            <param name="ConversionPattern" value="%d %-5p [%c] %m%n"/> 
    <category name="org.jboss.ejb.plugins.cmp">
        <priority value="DEBUG" ></priority>
        <appender-ref ref="CMP"></appender-ref>



    This creates a new file appender named CMP, which rights to the file cmp.log and specifies that DEBUG level output from the logger category org.jboss.ejb.plugins.cmp should be sent to that appender.


    For EJB3 with Hibernate you can use:


       <!-- print actual SQL -->
       <category name="org.hibernate.SQL">
          <priority value="debug"></priority>
       <!-- print EJBQL and parameters -->
       <category name="org.hibernate.impl.SessionImpl">
            <priority value="debug"></priority>
       <category name="org.hibernate.engine.QueryParameters">
            <priority value="debug" ></priority>