Tuesday, 2 June 2020

Printing SQL queries in Alfresco logs

Many a times, we are required to print the database SQL queries being called by the Alfresco APIs internally.
In order to do that, we can perform the steps below and restart alfresco server.

Go to log4j.properties in tomcat/webapps/alfresco/WEB-INF/classes
Edit the same, modify the rootLogger as below.

log4j.rootLogger=debug, error, Console, File

And add the following statements (if not already existing):

# SqlMap logging configuration.
log4j.logger.com.ibatis=DEBUG
log4j.logger.com.ibatis.common.jdbc.SimpleDataSource=DEBUG
log4j.logger.com.ibatis.common.jdbc.ScriptRunner=DEBUG
log4j.logger.com.ibatis.sqlmap.engine.impl.SqlMapClientDelegate=DEBUG
log4j.logger.java.sql=DEBUG
log4j.logger.java.sql.Connection=DEBUG
log4j.logger.java.sql.Statement=DEBUG
log4j.logger.java.sql.PreparedStatement=DEBUG
log4j.logger.java.sql.ResultSet=DEBUG

Go to : https://<hostname>/alfresco/s/enterprise/admin/admin-log-settings

Find 'root' . Set it to DEBUG.
Once done printing the required sql queries, reset this 'root' again to 'ERROR' else, your logs will be flooded.