NutzCN Logo
问答 Druid-慢SQL日志记录 在nutz里datasource如何配置
发布于 3042天前 作者 qq_e6f1efca 3635 次浏览 复制 上一个帖子 下一个帖子
标签:

http://www.tuicool.com/articles/FnaI7br 想要实现左边链接的功能,在nutz里datasource如何配置.
dataSource:{
type:"com.alibaba.druid.pool.DruidDataSource",
fields:{
url:{java :"$config.get('db-url')"},
username:{java :"$config.get('db-username')"},
password:{java :"$config.get('db-password')"},
initialSize:5,
minIdle:1,
maxActive:100,
timeBetweenEvictionRunsMillis:3000,
minEvictableIdleTimeMillis:300000,
poolPreparedStatements:"true",
maxPoolPreparedStatementPerConnectionSize:20,
maxWait:60000,
filters:"log4j"
}
}

5 回复

纯粹ioc定义转换问题

<bean id="stat-filter" class="com.alibaba.druid.filter.stat.StatFilter">
  <property name="mergeSql" value="true" />
  <property name="slowSqlMillis" value="1000" />
  <property name="logSlowSql" value="true" />
</bean>

转义nutz ioc js表达:

"stat-filter" : {
    type : "com.alibaba.druid.filter.stat.StatFilter",
	fields : {
	    mergeSql : true,
		slowSqlMillis : 1000,
		logSlowSql : true
	}
}
// 
dataSource:{
    type:"com.alibaba.druid.pool.DruidDataSource",
    fields:{
        url:{java :"$config.get('db-url')"},
        username:{java :"$config.get('db-username')"},
        password:{java :"$config.get('db-password')"},
        initialSize:5,
        maxActive:100,
        timeBetweenEvictionRunsMillis:3000,
        minEvictableIdleTimeMillis:300000,
        poolPreparedStatements:"true",
        maxPoolPreparedStatementPerConnectionSize:20,
        maxWait:60000,
        filters:"log4j",
		proxyFilters : [{refer:"stat-filter"}]
     }
 }

谢谢^^ 做这种配置之后 info_slowsql.log输出来的日志无sql,请问一下是什么原因导致的?

log4j的配置如下:
log4j.rootLogger = info,stdout,D,nutz,warn,A1,A2

\u8F93\u51FA\u5230\u63A7\u5236\u53F0

log4j.appender.stdout = org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target = System.out
log4j.appender.stdout.layout = org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern = %d [%t] %p %c - %m %n

\u8F93\u51FA\u5230\u65E5\u5FD7\u6587\u4EF6

log4j.appender.debug = org.apache.log4j.DailyRollingFileAppender
log4j.appender.debug.File = ${catalina.home}/logs/mk-eam-debug.log
log4j.appender.debug.datePattern=yyyy-MM-dd'.log'
log4j.appender.debug.Append = true

\u8F93\u51FADEBUG\u7EA7\u522B\u4EE5\u4E0A\u7684\u65E5\u5FD7

log4j.appender.debug.Threshold = INFO
log4j.appender.debug.layout = org.apache.log4j.PatternLayout
log4j.appender.debug.layout.ConversionPattern = %-d{yyyy-MM-dd HH:mm:ss,SSS} [ %t:%r ] - [ %p ] %m%n

\u4FDD\u5B58\u5F02\u5E38\u4FE1\u606F\u5230\u5355\u72EC\u6587\u4EF6

log4j.appender.D = org.apache.log4j.DailyRollingFileAppender

\u5F02\u5E38\u65E5\u5FD7\u6587\u4EF6\u540D

log4j.appender.D.File = ${catalina.home}/logs/mk-eam-error.log
log4j.appender.D.datePattern=yyyy-MM-dd'.log'

log4j.appender.D.Append = true

\u53EA\u8F93\u51FAERROR\u7EA7\u522B\u4EE5\u4E0A\u7684\u65E5\u5FD7!!!

log4j.appender.D.Threshold = ERROR
log4j.appender.D.layout = org.apache.log4j.PatternLayout
log4j.appender.D.layout.ConversionPattern = %-d{yyyy-MM-dd HH:mm:ss,SSS} [%X{username}] [ %t:%r ] - [ %p ] %m%n

nutz\u65E5\u5FD7\u6587\u4EF6

log4j.appender.nutz = org.apache.log4j.DailyRollingFileAppender
log4j.appender.nutz.File = ${catalina.home}/logs/nutz.log
log4j.appender.nutz.append = true
log4j.appender.nutz.encoding=UTF-8
log4j.appender.nutz.layout = org.apache.log4j.PatternLayout
log4j.appender.nutz.layout.ConversionPattern = %-d{yyyy-MM-dd HH:mm:ss,SSS} [%X{username}] [ %t:%r ] - [ %p ] %m%n

nutz log info controller

log4j.category.org.nutz=debug
log4j.category.org.nutz.dao=debug
log4j.category.org.nutz.ioc=debug
log4j.category.org.nutz.mvc=debug

Druid

log4j.logger.druid.sql=info,A1,A2
log4j.logger.druid.sql.DataSource=info,A1,A2
log4j.logger.druid.sql.Connection=info,A1,A2
log4j.logger.druid.sql.Statement=info,A1,A2
log4j.logger.druid.sql.ResultSet=info,A1,A2

log4j.appender.A1=org.apache.log4j.DailyRollingFileAppender
log4j.appender.A1.File=${catalina.home}/info_slowsql.log
log4j.appender.A1.DatePattern='.'yyyy-MM-dd

log4j.appender.A1.File=${catalina.home}/logs/info_slowsql.log

log4j.appender.A1.File=${WebApp.TomcatHome}/logs/info_slowsql.log

log4j.appender.A1.ImmediateFlush=true
log4j.appender.A1.Append=true
log4j.appender.A1.Threshold=info
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern=[%d{yyyy-MM-dd HH:mm:ss}] [%p] [%c] - %m%n

log4j.appender.A2=org.apache.log4j.DailyRollingFileAppender
log4j.appender.A2.File=${catalina.home}/warn_slowsql.log
log4j.appender.A2.DatePattern='.'yyyy-MM-dd

log4j.appender.A2.File=${catalina.home}/logs/warn_slowsql.log

log4j.appender.A2.File=${WebApp.TomcatHome}/logs/warn_slowsql.log

log4j.appender.A2.ImmediateFlush=true
log4j.appender.A2.Append=true
log4j.appender.A2.Threshold=warn
log4j.appender.A2.layout=org.apache.log4j.PatternLayout
log4j.appender.A2.layout.ConversionPattern=[%d{yyyy-MM-dd HH:mm:ss}] [%p] [%c] - %m%n

log4j.appender.A1.Threshold=info

应该是debug级别吧

还是不行哦 不知道是什么原因

统统改成debug

添加回复
请先登陆
回到顶部