我正在使用 grails 2.0.4。即使 sql profiler 客户端正在连接;p6spy 没有记录任何内容。
我怀疑问题出在属性文件上,或者与我的 Config.groovy log4j 设置有冲突。
• 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
• 数据源.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'
}