开发者

How does P6SPY work?

开发者 https://www.devze.com 2023-03-20 19:46 出处:网络
Pretty much everything in the question. I just dis开发者_如何学运维covered p6spy in association with hibernate which is really cool to see the actual sql queries, though I\'m quite baffled on how it w

Pretty much everything in the question. I just dis开发者_如何学运维covered p6spy in association with hibernate which is really cool to see the actual sql queries, though I'm quite baffled on how it works.

So how does it work?


the basic idea on p6spy goes like this:

  1. depending if you go for Datasource or for JDBC driver in your code, what you do is instead of referring the real ones, you specify p6spy specific ones: com.p6spy.engine.spy.P6SpyDriver or com.p6spy.engine.spy.P6DataSource respectively (for full documentation, see: p6spy.readthedocs.io/en/latest/configandusage.html).
  2. afterwards you configure the real ones in your spy.properties file (using realdriver or realdatasource properties respectively)
  3. depending on the configuration you can achieve the logging of sql statements (using com.p6spy.engine.logging.P6LogFactory)
  4. so to answer your question, the idea is that all the jdbc calls (statements execution, transaction related stuff) will be wrapped (proxied) by p6spy and depending on your configuration, these can be logged via the file logger (using appender=com.p6spy.engine.logging.appender.FileLogger), stdout logger (using appender=com.p6spy.engine.logging.appender.StdoutLogger) or log4j logger (using: appender=com.p6spy.engine.logging.appender.Log4jLogger)

If interested in more details, feel free to ask, or check the project itself on: https://github.com/p6spy/p6spy

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号