使用javamelody进行web监控
1、引入maven依赖
<dependency>
<groupId>net.bull.javamelody</groupId>
<artifactId>javamelody-core</artifactId>
<version>1.70.0</version>
</dependency>`
2、配置web.xml
初始化启动参数增加monitoring-spring.xml
<filter>
<filter-name>javamelody</filter-name>
<filter-class>net.bull.javamelody.MonitoringFilter</filter-class>
<async-supported>true</async-supported>
</filter>
<filter-mapping>
<filter-name>javamelody</filter-name>
<url-pattern>/monitoring</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>ASYNC</dispatcher>
</filter-mapping>
<filter-mapping>
<filter-name>javamelody</filter-name>
<url-pattern>/rest/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>ASYNC</dispatcher>
</filter-mapping>
<listener>
<listener-class>net.bull.javamelody.SessionListener</listener-class>
</listener>
3、监控的地址
http://ip:port/serverName/monitoring
4、更多的参考
https://github.com/javamelody/javamelody/wiki
5、问题总结
c3p0数据源怎么监控
<bean id="mainDataSource" class="net.bull.javamelody.SpringDataSourceFactoryBean">
<property name="targetName" value="dataSource" />
</bean>
6、springboot集成javamelody
引入依赖
<dependency>
<groupId>net.bull.javamelody</groupId>
<artifactId>javamelody-core</artifactId>
<version>1.72.0</version>
</dependency>
```
@Configuration
public class JavamelodyConfiguration {
@Bean
public FilterRegistrationBean monitorFilter() {
FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean(new MonitoringFilter());
filterRegistrationBean.addUrlPatterns("/*");
return filterRegistrationBean;
}
@Bean
public ServletListenerRegistrationBean sessionListener() {
ServletListenerRegistrationBean servletListenerRegistrationBean = new ServletListenerRegistrationBean();
servletListenerRegistrationBean.setListener(new SessionListener());
return servletListenerRegistrationBean;
}
}
更多精彩,敬请关注, 程序员导航网
版权声明:本文为人工博客的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
本文链接:https://www.gzcx.net/article/11
正文到此结束
- 本文标签: java Spring Boot
- 版权声明: 本站原创文章,于2019年07月20日由Mars发布,转载请注明出处