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.

2 comments:

  1. Hi Sanket

    I have read your article about Replication services and Currently working on similar reqt.I have few questions regarding the Replication Service in alfresco ,if you might answer it :

    1.)In which scenarios it should be preferable to use replication services.
    Firstly,Is there any limit on data that can be migrated using replication services.
    Secondly,Is it possible to export/import custom metadata along with docs and versions of files.
    The aim is to migrate documents from one alfresco instance to another with minimal changes at target repository side.
    Could you please help in suggesting in what use cases i must go with above approach.

    Thanks !
    Ashita saxena

    ReplyDelete
  2. Thanks a lot I have read your article i solved my problem...
    large outdoor banners in pakistan

    ReplyDelete