Reputation: 51
I am using grails 2.0.4. Even though the sql profiler client is connecting; p6spy is not logging anything.
I suspect that the problem lies in the property file, or that there is a conflict with my Config.groovy log4j settings.
• spy.properties
module.log=com.p6spy.engine.logging.P6LogFactory
realdriver=oracle.jdbc.driver.OracleDriver
dateformat=HH:mm:ss
deregisterdrivers=false
executionthreshold=
outagedetection=false
outagedetectioninterval=
filter=false
include =
exclude =
sqlexpression =
autoflush= true
includecategories=
excludecategories=
stringmatcher=
stacktrace=false
stacktraceclass=
reloadproperties=false
reloadpropertiesinterval=60
useprefix=false
appender=com.p6spy.engine.logging.appender.Log4jLogger
append=true
log4j.appender.SQLPROFILER_CLIENT=org.apache.log4j.net.SocketAppender
log4j.appender.SQLPROFILER_CLIENT.RemoteHost=localhost
log4j.appender.SQLPROFILER_CLIENT.Port=4445
log4j.appender.SQLPROFILER_CLIENT.LocationInfo=true
log4j.logger.p6spy=DEBUG,SQLPROFILER_CLIENT
• DataSource.groovy
dataSource {
pooled = true
logSql = true
//driverClassName = "oracle.jdbc.driver.OracleDriver"
driverClassName = "com.p6spy.engine.spy.P6SpyDriver" // use this driver to enable p6spy logging
dialect = 'org.hibernate.dialect.Oracle10gDialect'
}
• Config.Groovy
// log4j configuration
log4j = {
appenders {
console name:'stdout', layout:pattern(conversionPattern: '%d{ISO8601} [%c{1}] %p: %m%n')
}
info 'grails.app' // Logging warnings and higher for all of the app
error 'org.codehaus.groovy.grails.web.servlet', // controllers
'org.codehaus.groovy.grails.web.pages', // GSP
'org.codehaus.groovy.grails.web.sitemesh', // layouts
'org.codehaus.groovy.grails.web.mapping.filter', // URL mapping
'org.codehaus.groovy.grails.web.mapping', // URL mapping
'org.codehaus.groovy.grails.commons', // core / classloading
'org.codehaus.groovy.grails.plugins', // plugins
'org.codehaus.groovy.grails.orm.hibernate', // hibernate integration
'org.springframework',
'org.hibernate',
'net.sf.ehcache.hibernate'
trace 'org.hibernate.type'
}
Upvotes: 2
Views: 741
Reputation: 848
The most likely cause of this problem is that the Oracle JDBC driver is being registered by DriverManager before P6SpyDriver. P6Spy 1.3 requires that P6SpyDriver gets registered before the real driver. This is what allowed it to work without any modifications to the JDBC URL.
There are two potential solutions to this issue.
1) Set 'deregisterdrivers=false' in spy.properties. This will cause the driver configured as the 'realdriver' in spy.properties to be deregistered and reregistered when P6SpyDriver is loaded. This enforces the correct ordering within DriverManager.
2) Set 'useprefix=true' in spy.properties and add the prefix 'p6spy:' to your JDBC URL. Since the JDBC URL is different, the order of registration no longer matters.
Further troubleshooting tips: http://p6spy.github.io/p6spy/1.3/troubleshooting.html
Upvotes: 1
Reputation: 5955
I had some issues with P6Spy not detecting the right driver for H2. In the end I went with log4jdbc. It has more recent updates to its code. P6Spy hasn't been updated in quite sometime, but maybe there has been no need to. I scribbled a few lines in my blog on my experience of log4jdbc, grails and tomcat7. It might be of some use to you!
Upvotes: 0