How do I get SqlMapClient to log SQL statements
iBATIS uses commons-logging to log these.
iBatis用commons-logging來記錄這些日志。
Depending on your logging implementation, your configuration may vary.
依賴于你的日志實現,你的配置可能改變。
If you are using log4j, put this line into log4j.properties:
如果你用log4j,把下面這行放入log4j.properties:
log4j.logger.java.sql=DEBUG
If you set your default log level to DEBUG, that will work, too...but you will get debug level logging for everything in the world.
如果你設置默認的日志級別為DEBUG,他將工作,但是你獲得全世界每個debug級別的日志。
Here is another example of how to configure ibatis with log4j using an xml config file.
下面是另一個例子,怎么樣用xml格式的log4j配置ibatis
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"> <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"> <!-- Console output --> <appender name="STDOUT" class="org.apache.log4j.ConsoleAppender"> <layout class="org.apache.log4j.PatternLayout"> <param name="ConversionPattern" value="%-5p %d{MM-dd HH:mm:ss} %m (%F:%L) \n"/> </layout> </appender> <category name="com.ibatis"> <priority value="debug" /> </category> <category name="java.sql"> <priority value="debug" /> </category> <!--The root category defines the top level of appenders all catagories inherit --> <root> <priority value ="error" /> <appender-ref ref="STDOUT" /> </root> </log4j:configuration>
A common question is "Is it possible to show the ACTUAL query being executed?".
一個更通常的問題:有可能展示某個真正的查詢被執行了嗎?
The simple answer is NO.
簡單得回答:沒有
Why? Because the only information we have available is the PreparedStatement and the parameters.
為什么?因為我們只能獲得preparestatement和參數
Quite often, in the process of applying those parameters to the mapped statement it will become very clear where issues lie in the execution of the query.
更經常,在把參數匹配到statement這個過程中,很明顯能看出查詢過程哪里有問題。
If you feel that you NEED to see the completed query, you may be interested in hooking up a debugging tool like p6spy, as it may answer your questions for you.
如果你項看到完整得查詢,你最好用p6spy這樣得debug工具。
For WebSphere-specific instructions see also How do I Configure Logging in WebSphere.
Websphare規范簡介參考W@!#%@%RQEWRWQR
posted on 2008-07-22 22:51 MingIsMe 閱讀(83) 評論(0) 編輯 收藏 所屬分類: iBatis學習