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