DRUID连接池的实用 配置详解
DRUID连接池的实用 配置详解 bean>上面红色标注部分为监控DB连接执行监控,后面在做详细说明·监控方式1、WEB方式监控配置Druidstat View com.alibabadruidsupporthttpstatviewservlet Druid Stat View /druid/* druidwebstat Filter com.alibabadruidsupporthttpWebstatfilter exclusions /public/** js, * css druid* . jsp swf principalSession Name sessionInfa profile Enable true druidWebstat Filter url-pattern>/* 把上面sere配置添加到项目web.xm即可。然后运行Tomcat,洳览器输入http://ip:Prot/DruiD就可以打开Drud的监控页面了2、日志文件监控Druid提供了多种口志文件监控 commons- logging、lag4j等,这里我们主要使用sf4j和 Hogback来进行日志监控配置。首先要引入sf4j和logback相关的jar文件(从Maven公共仓库下载http://search.mavenorg/)1. 7.l1.2 org. slf 4j slf4j-apicyartifactId>$slf4j version ch qos logback logback-access$logback. version ch. gos logback logback-core sartifactId>log back. version] ch qos logback sartifactId>logback-classic sartifactId>logback. version] 接下配置 logback的配置文件(/conf/ hogback.Xm)appender name=STDOUT"class="ch gos logback. core. Console Appender>file>/ logs/druid_ info. logevel>debug Appender> 最后就是写一个测试类进行测试public class TestMainpublic static void loadLoggerContexto tLoggerContext Ic=( LoggerContext) LoggerFactory getILoggerFactory();25System get Properties( put( logback. configurationFile ,"./conf/ logback. xml")Stat us Printer. setPrint Stream( System. errStat us Printer print(Ic)public static void main(String] argsiloadLoggerContextoFileSystemXmlApplication Context context new File SystemXmlApplicationContext( /conf/ spring-base. xml);s catch(Exception etSystem. out. printin(e);标签: DRUID连接池配置详解
用户评论