[JBoss] Logging JBoss CMP SQL - Digizol6

Post Top Ad

Responsive Ads Here

Post Top Ad

Responsive Ads Here

Sunday, October 8, 2006

[JBoss] Logging JBoss CMP SQL

JBossIn many occassions developers tend to get errors when calling the CMP finders. The best method to fix such issues is to view the generated SQL queries, as it's easy to understand the error in terms of general SQL rather than looking at the EJB-QLs.

With the help of log4j, CMP generated SQLs can be logged into a file as follows.

1. Goto the conf folder inside your server instance.
2. Open the log4j.xml file and add the following two entries to it.

<appender name="CMP" class="org.jboss.logging.appender.RollingFileAppender">
<errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
<param name="File" value="/log/cmpSQL.log"/>
<param name="Append" value="false"/>
<param name="MaxFileSize" value="800KB"/>
<param name="MaxBackupIndex" value="1"/>
<layout class="org.apache.log4j.xml.XMLLayout"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d %-5p [%c] %m%n"/>
</layout>
</appender>

<category name="org.jboss.ejb.plugins.cmp">
<priority value="DEBUG" />
<appender-ref ref="CMP"/>
</category>

With the above given entries, a file named cmpSQL.log will be created inside the log folder. SQLs send to the server will be logged into this file. If required, name and place of the log file can be changed by changing the value in File param.
<param name="File" value="/log/cmpSQL.log"/>


No comments:

Post a Comment

Post Top Ad

Responsive Ads Here