springmvc+mybatis怎么获取sql语句
1个回答
2016-04-17
展开全部
在web.xml配置文件中加入Log4j的配置,部分配置文件如下:
<!--Log4j配置-->
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>/WEB-INF/log4j.xml</param-value>
</context-param>
<context-param>
<param-name>log4jRefreshInterval</param-name>
<param-value>60000</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>
<!-- 扫描spring配置文件 -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:spring/application-*.xml</param-value>
</context-param>
<!-- 监听器 -->
<listener>
<listener-class>com.hanvon.iface.web.listener.WebAppEventListener</listener-class>
<仿弊/listener>
.......
增加了上面的Log4j配置部分后,结果真的可以打印SQL 语句了,太高兴了得意!姿拦!!
我觉得,起作用的主要是下面备册族的配置内容,这个配置正确设置了Log4j:
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>/WEB-INF/log4j.xml</param-value>
</context-param>
<context-param>
<param-name>log4jRefreshInterval</param-name>
<param-value>60000</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>
<!--Log4j配置-->
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>/WEB-INF/log4j.xml</param-value>
</context-param>
<context-param>
<param-name>log4jRefreshInterval</param-name>
<param-value>60000</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>
<!-- 扫描spring配置文件 -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:spring/application-*.xml</param-value>
</context-param>
<!-- 监听器 -->
<listener>
<listener-class>com.hanvon.iface.web.listener.WebAppEventListener</listener-class>
<仿弊/listener>
.......
增加了上面的Log4j配置部分后,结果真的可以打印SQL 语句了,太高兴了得意!姿拦!!
我觉得,起作用的主要是下面备册族的配置内容,这个配置正确设置了Log4j:
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>/WEB-INF/log4j.xml</param-value>
</context-param>
<context-param>
<param-name>log4jRefreshInterval</param-name>
<param-value>60000</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询