1. 首页
  2. 编程语言
  3. Java
  4. DRUID连接池的实用 配置详解

DRUID连接池的实用 配置详解

上传者: 2018-12-25 17:24:31上传 PDF文件 102.45KB 热度 30次
DRUID连接池的实用 配置详解bean>上面红色标注部分为监控DB连接执行监控,后面在做详细说明·监控方式1、WEB方式监控配置Druidstat View com.alibabadruidsupporthttpstatviewservletDruid Stat View /druid/*druidwebstat Filter com.alibabadruidsupporthttpWebstatfilterexclusions /public/** js, * css druid* . jsp swf principalSession Name sessionInfaprofile Enable truedruidWebstat 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.2org. slf 4jslf4j-apicyartifactId>$slf4j versionch qos logbacklogback-access$logback. versionch. gos logbacklogback-core sartifactId>log back. version]ch qos logbacksartifactId>logback-classic sartifactId>logback. version]接下配置 logback的配置文件(/conf/ hogback.Xm)appender name=STDOUT"class="ch gos logback. core. Console Appender>od HH: mm: ssSSS[%thread]%-5level %logger 36-%msg%nevel>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连接池配置详解
用户评论
码姐姐匿名网友 2018-12-25 17:24:31

挺好的,选择用spring-boot-druid-starter更方便