My favorites | Sign in
Project Home Downloads Wiki Issues Source
Project Information
Members
Links

A simple tool to capture hql and sql for web flows.

Introduction

Quick profiler works out of a spring file and a single jar file and uses log4j NDC for grouping queries (hqls and sqls for a flow). The jar file adds logging of more events to hibernate and ships with a custom layout to help visualizing the queries. The queries are presented in an xml format which can be viewed in any xml editor. We are also working on an Analyzer which could suggest hints. For sample output refer to Sample Output

Steps to setup

  1. Drop the quick-profiler.jar into web-inf/lib or any folder on your web-app classpath.
  2. Export the statistics service bean via jmx (refer to the spring-profile.xml, instead of the default StatisticsService use LoggingContextAwareStatisticsService)
  3. If there is no NDC set, enable usage of one via the LoggingFilter (Refer to NDC Section )
  4. Enable logging of the stats using SqlLayout (refer to Logging Configuration section)

Logging Configuration

The extra logging parameters can be:

  • log4j.appender.SqlTraceAppender=org.apache.log4j.RollingFileAppender
  • log4j.appender.SqlTraceAppender.File=server_home/logs/sqlTrace.xml
  • log4j.appender.SqlTraceAppender.layout=org.webscale.hibernate.profiling.layout.SqlLayout
  • log4j.category.org.webscale.hibernate.profiling.FlowAwareSessionStatsCollector=INFO,SqlTraceAppender

This is our normal log4j configuration, except that the layout is a custom one. We also need to enable tracing, which can be done with

NDC Section

One of the features that log4j supports is NDC, it helps adding an context to the subsequent log messages for easier grouping. We can use the request URI as the NDC, the filter class LoggingFilter (java servlet spec Filter, not hibernate filters) can be one such filter which can add an context Based on this NDC we can control which flows to log details about and other such details.

Powered by Google Project Hosting