#Time logging utilities for each external interaction
- JDBC query timing interceptor
- Servlet filter to do request ID correlation
- Build the project
mvn clean install
-
Copy "org.wso2.carbon.identity.ext.pool.db.interceptor-0.0.1-SNAPSHOT.jar" to dropins
-
Add following property to datasource configuration
<jdbcInterceptors>org.wso2.carbon.identity.ext.jdbc.pool.interceptor.TimeLogInterceptor</jdbcInterceptors>
e.g. in master-datasource.xml
<datasource>
<name>WSO2_CARBON_DB</name>
<description>The datasource used for registry and user manager</description>
<jndiConfig>
<name>jdbc/WSO2CarbonDB</name>
</jndiConfig>
<definition type="RDBMS">
<configuration>
<url>jdbc:h2:./repository/database/WSO2CARBON_DB;DB_CLOSE_ON_EXIT=FALSE;LOCK_TIMEOUT=60000</url>
<username>wso2carbon</username>
<password>wso2carbon</password>
<driverClassName>org.h2.Driver</driverClassName>
<maxActive>50</maxActive>
<maxWait>60000</maxWait>
<testOnBorrow>true</testOnBorrow>
<validationQuery>SELECT 1</validationQuery>
<validationInterval>30000</validationInterval>
<defaultAutoCommit>false</defaultAutoCommit>
<jdbcInterceptors>org.wso2.carbon.identity.ext.jdbc.pool.interceptor.TimeLogInterceptor</jdbcInterceptors>
</configuration>
</definition>
</datasource>
- Add time-log as rolling file appender in log4j.properties
# Appender config to put Time Log.
# Appender config to put Time Log.
log4j.logger.TIME_LOG=DEBUG, TIME_LOG
log4j.additivity.TIME_LOG=false
log4j.appender.TIME_LOG = org.apache.log4j.RollingFileAppender
log4j.appender.TIME_LOG.File = ${carbon.home}/repository/logs/${instance.log}/timing${instance.log}.log
log4j.appender.TIME_LOG.Append = false
log4j.appender.TIME_LOG.layout = org.apache.log4j.PatternLayout
log4j.appender.TIME_LOG.layout.ConversionPattern=[%X{Correlation-ID}] %t - %m%n
-
Copy "org.wso2.carbon.identity.ext.servlet.filter-0.0.1-SNAPSHOT.jar" to dropins
-
Add following to "repository/conf/tomcat/web.xml"
<filter>
<filter-name>RequestCorrelationIdFilter</filter-name>
<filter-class>org.wso2.carbon.identity.ext.servlet.filter.RequestCorrelationIdFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>RequestCorrelationIdFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
- Change the following pattern in the "repository/conf/log4.properties"
# e.g. [%X{Correlation-ID}]
log4j.appender.CARBON_CONSOLE.layout.ConversionPattern=[%d] %P%5p {%c} - %x [%X{Correlation-ID}] %m%n
...
...
log4j.appender.CARBON_LOGFILE.layout.ConversionPattern=TID: [%T] [%S] [%d] %P%5p {%c} - %x [%X{Correlation-ID}] %m %n