---
title: "p6spy如何监控复杂web系统的sql语句，内有实验记录"
author: "onho"
date: "2010-05-21T14:08:14Z"
tags: []
categories: ["编程语言"]
slug: "p6spy-web-sql"
draft: false
lastmod: "2010-05-21T14:08:14Z"
id: 671696
url: "https://onho.iteye.com/blog/671696"
---

**一个部署比较复杂的web系统，无源码，想用p6spy抓获sql语句，查阅网上大量的资料之后，并做实验之后，发现还是不能抓出sql语句，估计是web系统部署太复杂的原因，请教我应该怎么设置p6spy。**

 

 

**1、一个web系统有多个应用组成，使用同一个登录页面，web系统的的目录结构如下：**

 

 

```
|---3rdparty
|       |---apache-tomcat-6.0.18
|       |                   |---lib
|       |                   |---temp
|       |                   |---bin
|       |                   |---work
|       |                   |---conf
|       |                   |---webapps
|---bin
|---reports
|---etc
|    |---apache
|    |---tomcat
|    |---init.d
|---common
|     |---lib              ------这个目录下面p6spy.jar，放在其他lib目录下面web服务起不来
|     |---classes      ------这个目录下面spy.properties，因为链接数据库的配置文件在此目录，放在其他classes目录web下面服务起不来
|     |      |---bshcommands
|---webapps
|      |---app1
|      |          |---WEB-INF
|      |          |      |---lib
|      |          |      |---classes
|      |          |---common
|      |          |     |---javascript
|      |          |     |---xslt
|      |          |     |---flashfiles
|      |          |     |---vbscript
|      |          |     |---images
|      |          |     |     |---tabs
|      |          |     |     |---configuration
|      |          |     |     |---tableHeader
|      |          |     |---css
|      |---app2
|      |    |---WEB-INF
|      |    |      |---lib
|      |    |      |---classes
|      |    |---inc
|      |---app3
|      |    |---WEB-INF
|      |    |      |---lib
|      |    |      |---classes
|      |    |---inc
|      |---app4
|      |     |---WEB-INF
|      |     |      |---lib
|      |     |      |---classes
|      |     |---inc
|      |---app5
|      |    |---WEB-INF
|      |    |      |---lib
|      |    |      |---classes
|      |    |---inc
|      |---app6
|      |      |---WEB-INF
|      |      |      |---lib
|      |      |      |---classes
|      |---app7
|      |     |---WEB-INF
|      |     |      |---lib
|      |     |      |---classes
|      |     |---common
|      |     |     |---javascript
|      |     |     |---images
|      |     |     |     |---tabs
|      |     |     |---css
```

2、common/classes下面存放连接数据库的配置文件；

3、复制p6spy.jar到common/lib目录下面，spy.properties复制到common/classes目录下面，已经修改了spy.properties文件的以下内容：

        realdriver=oracle.jdbc.driver.OracleDriver

        appender=com.p6spy.engine.logging.appender.Log4jLogger

        logfile     = spy.log

        spy.properties文件的其它内容没有修改，默认状态。

4、执行上述目录结构bin下面的启动脚本，web服务能够正常启动，web系统也能够正常使用，spy.log文件生成在上述目录结构的根目录，spy.log内容如下：

       1274235196764|-1||debug||com.p6spy.engine.common.P6SpyOptions reloading properties

```
1274235196769|-1||info||Using properties file: /opt/xxx/xxxx/common/classes/spy.properties
1274235196769|-1||info||No value in environment for: getStackTrace, using: false
1274235196769|-1||info||No value in environment for: getFilter, using: false
1274235196769|-1||info||No value in environment for: getAppender, using: com.p6spy.engine.logging.appender.Log4jLogger
1274235196769|-1||info||No value in environment for: getAppend, using: true
1274235196769|-1||info||No value in environment for: getDeregisterDrivers, using: false
1274235196769|-1||info||No value in environment for: getUsePrefix, using: false
1274235196769|-1||info||No value in environment for: getExecutionThreshold, using: 0
1274235196769|-1||info||No value in environment for: getAutoflush, using: true
1274235196769|-1||info||No value in environment for: getExclude, using: 
1274235196769|-1||info||No value in environment for: getExcludecategories, using: info,debug,result,batch
1274235196769|-1||info||No value in environment for: getInclude, using: 
1274235196769|-1||info||No value in environment for: getIncludecategories, using: 
1274235196769|-1||info||No value in environment for: getLogfile, using: spy.log
1274235196770|-1||info||No value in environment for: getRealdriver, using: oracle.jdbc.driver.OracleDriver
1274235196770|-1||info||No value in environment for: getRealdriver2, using: 
1274235196770|-1||info||No value in environment for: getRealdriver3, using: 
1274235196770|-1||info||No value in environment for: getSpydriver, using: com.p6spy.engine.spy.P6SpyDriver
1274235196770|-1||info||No value in environment for: getDateformat, using: 
1274235196770|-1||info||No value in environment for: getDateformatter, using: null
1274235196770|-1||info||No value in environment for: getStringmatcher, using: com.p6spy.engine.common.SubstringMatcher
1274235196770|-1||info||No value in environment for: getStringMatcherEngine, using: com.p6spy.engine.common.SubstringMatcher@81a197
1274235196770|-1||info||No value in environment for: getStackTraceClass, using: 
1274235196770|-1||info||No value in environment for: getSQLExpression, using: null
1274235196770|-1||info||No value in environment for: getReloadProperties, using: false
1274235196770|-1||info||No value in environment for: getReloadPropertiesInterval, using: 60
1274235196770|-1||info||No value in environment for: getJNDIContextFactory, using: null
1274235196770|-1||info||No value in environment for: getJNDIContextProviderURL, using: null
1274235196770|-1||info||No value in environment for: getJNDIContextCustom, using: null
1274235196770|-1||info||No value in environment for: getRealDataSource, using: null
1274235196770|-1||info||No value in environment for: getRealDataSourceClass, using: null
1274235196770|-1||info||No value in environment for: getRealDataSourceProperties, using: null
```

   5、此时执行web页面的任何功能，spy.log下面再无新的内容出现。

 

 

对于这样的情况，我应该怎样配置p6spy，请大家多多帮忙，谢谢、谢谢。。。