druid,log4j记录sql,发现会执行三次,

发布于 2021-12-05 13:17:52 字数 2227 浏览 830 评论 12

2014-10-27 16:51:30,146 DEBUG [druid.sql.Statement] - <{conn-10002, pstmt-20001} created. select count(id) from User>
2014-10-27 16:51:30,146 DEBUG [druid.sql.Statement] - <{conn-10002, pstmt-20001} created. select count(id) from User>
2014-10-27 16:51:30,146 DEBUG [druid.sql.Statement] - <{conn-10002, pstmt-20001} created. select count(id) from User>
2014-10-27 16:51:30,147 DEBUG [druid.sql.Statement] - <{conn-10002, pstmt-20001} Parameters : []>
2014-10-27 16:51:30,147 DEBUG [druid.sql.Statement] - <{conn-10002, pstmt-20001} Parameters : []>
2014-10-27 16:51:30,147 DEBUG [druid.sql.Statement] - <{conn-10002, pstmt-20001} Parameters : []>
2014-10-27 16:51:30,147 DEBUG [druid.sql.Statement] - <{conn-10002, pstmt-20001} Types : []>
2014-10-27 16:51:30,147 DEBUG [druid.sql.Statement] - <{conn-10002, pstmt-20001} Types : []>
2014-10-27 16:51:30,147 DEBUG [druid.sql.Statement] - <{conn-10002, pstmt-20001} Types : []>
2014-10-27 16:51:30,148 DEBUG [druid.sql.Statement] - <{conn-10002, pstmt-20001} executed. select count(id) from User>
2014-10-27 16:51:30,148 DEBUG [druid.sql.Statement] - <{conn-10002, pstmt-20001} executed. select count(id) from User>
2014-10-27 16:51:30,148 DEBUG [druid.sql.Statement] - <{conn-10002, pstmt-20001} executed. select count(id) from User>
2014-10-27 16:51:30,148 DEBUG [druid.sql.Statement] - <{conn-10002, pstmt-20001} executed. 1.089623 millis. select count(id) from User>
2014-10-27 16:51:30,148 DEBUG [druid.sql.Statement] - <{conn-10002, pstmt-20001} executed. 1.089623 millis. select count(id) from User>
2014-10-27 16:51:30,148 DEBUG [druid.sql.Statement] - <{conn-10002, pstmt-20001} executed. 1.089623 millis. select count(id) from User>
2014-10-27 16:51:30,148 DEBUG [druid.sql.Statement] - <{conn-10002, pstmt-20001} closed>
2014-10-27 16:51:30,148 DEBUG [druid.sql.Statement] - <{conn-10002, pstmt-20001} closed>
2014-10-27 16:51:30,148 DEBUG [druid.sql.Statement] - <{conn-10002, pstmt-20001} closed>


我访问了一次,从日志看,执行三次sql语句,怎么回事?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(12

梦中楼上月下 2021-12-08 21:39:08

把log4j里面的配置删除,spring里面配置的filter有log类型就可以了,还有就是sql不是执行了3次,而是打印了3遍

醉酒的小男人 2021-12-08 21:39:06

先把log中druid的配置去了试试

毁梦 2021-12-08 21:39:06

<2015-04-14 10:46:08> <DEBUG> [druid.sql.Statement] - {conn-10001, pstmt-20002} created. select logconfig0_.id as id22_, logconfig0_.create_date as create2_22_, logconfig0_.modify_date as modify3_22_, logconfig0_.action_class_name as action4_22_, logconfig0_.action_method_name as action5_22_, logconfig0_.description as descript6_22_, logconfig0_.operation_name as operation7_22_ from cf_log_config logconfig0_ order by logconfig0_.create_date desc

<2015-04-14 10:46:08> <DEBUG> [druid.sql.Statement] - {conn-10001, pstmt-20002} created. select logconfig0_.id as id22_, logconfig0_.create_date as create2_22_, logconfig0_.modify_date as modify3_22_, logconfig0_.action_class_name as action4_22_, logconfig0_.action_method_name as action5_22_, logconfig0_.description as descript6_22_, logconfig0_.operation_name as operation7_22_ from cf_log_config logconfig0_ order by logconfig0_.create_date desc

<2015-04-14 10:46:08> <DEBUG> [druid.sql.Statement] - {conn-10001, pstmt-20002} created. select logconfig0_.id as id22_, logconfig0_.create_date as create2_22_, logconfig0_.modify_date as modify3_22_, logconfig0_.action_class_name as action4_22_, logconfig0_.action_method_name as action5_22_, logconfig0_.description as descript6_22_, logconfig0_.operation_name as operation7_22_ from cf_log_config logconfig0_ order by logconfig0_.create_date desc

<2015-04-14 10:46:08> <DEBUG> [druid.sql.Statement] - {conn-10001, pstmt-20002} Parameters : []

<2015-04-14 10:46:08> <DEBUG> [druid.sql.Statement] - {conn-10001, pstmt-20002} Parameters : []

<2015-04-14 10:46:08> <DEBUG> [druid.sql.Statement] - {conn-10001, pstmt-20002} Parameters : []

<2015-04-14 10:46:08> <DEBUG> [druid.sql.Statement] - {conn-10001, pstmt-20002} Types : []

<2015-04-14 10:46:08> <DEBUG> [druid.sql.Statement] - {conn-10001, pstmt-20002} Types : []

<2015-04-14 10:46:08> <DEBUG> [druid.sql.Statement] - {conn-10001, pstmt-20002} Types : []

<2015-04-14 10:46:08> <DEBUG> [druid.sql.Statement] - {conn-10001, pstmt-20002, rs-50002} query executed. 3.397767 millis. select logconfig0_.id as id22_, logconfig0_.create_date as create2_22_, logconfig0_.modify_date as modify3_22_, logconfig0_.action_class_name as action4_22_, logconfig0_.action_method_name as action5_22_, logconfig0_.description as descript6_22_, logconfig0_.operation_name as operation7_22_ from cf_log_config logconfig0_ order by logconfig0_.create_date desc

<2015-04-14 10:46:08> <DEBUG> [druid.sql.Statement] - {conn-10001, pstmt-20002, rs-50002} query executed. 3.397767 millis. select logconfig0_.id as id22_, logconfig0_.create_date as create2_22_, logconfig0_.modify_date as modify3_22_, logconfig0_.action_class_name as action4_22_, logconfig0_.action_method_name as action5_22_, logconfig0_.description as descript6_22_, logconfig0_.operation_name as operation7_22_ from cf_log_config logconfig0_ order by logconfig0_.create_date desc

<2015-04-14 10:46:08> <DEBUG> [druid.sql.Statement] - {conn-10001, pstmt-20002, rs-50002} query executed. 3.397767 millis. select logconfig0_.id as id22_, logconfig0_.create_date as create2_22_, logconfig0_.modify_date as modify3_22_, logconfig0_.action_class_name as action4_22_, logconfig0_.action_method_name as action5_22_, logconfig0_.description as descript6_22_, logconfig0_.operation_name as operation7_22_ from cf_log_config logconfig0_ order by logconfig0_.create_date desc

<2015-04-14 10:46:08> <DEBUG> [druid.sql.Statement] - {conn-10001, pstmt-20002} clearParameters. 

<2015-04-14 10:46:08> <DEBUG> [druid.sql.Statement] - {conn-10001, pstmt-20002} clearParameters. 

<2015-04-14 10:46:08> <DEBUG> [druid.sql.Statement] - {conn-10001, pstmt-20002} clearParameters. 

<2015-04-14 10:46:08> <DEBUG> [druid.sql.Statement] - {conn-10001, pstmt-20002} closed

<2015-04-14 10:46:08> <DEBUG> [druid.sql.Statement] - {conn-10001, pstmt-20002} closed

<2015-04-14 10:46:08> <DEBUG> [druid.sql.Statement] - {conn-10001, pstmt-20002} closed

同求解决办法

平生欢 2021-12-08 21:38:57

我是在spring里使用的druid,您说的配置是指??

疑心病 2021-12-08 21:38:37

要druid配置

凯凯我们等你回来 2021-12-08 21:08:14

引用来自“echard”的评论

把配置以发出来

不乱于心 2021-12-08 20:17:26

把配置以发出来

剑心龙吟 2021-12-08 20:15:03

只配置了proxyFilters,没有filters

南冥有猫 2021-12-08 19:33:13

是不是同时配置了filter和proxyFilters

#过滤   如果同时配置了filters和proxyFilters,是组合关系,并非替换关系
#filters:config

建议在properties就配置个filters:config,用来加密数据库连接密码。然后在datasource里配置

<!-- 配置监控统计拦截的filters -->
<property name="proxyFilters">
<list>
<ref bean="stat-filter" />
<ref bean="wall-filter" />
<ref bean="log-filter" />
</list>
</property>

瑾夏年华 2021-12-08 18:42:40

引用来自“lgscofield”的评论

应该是log4j配置的问题吧

筱果果 2021-12-08 12:03:18

应该是log4j配置的问题吧

居里长安 2021-12-08 11:32:20

解决没有啊?求分享一下,

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文