javamelody应用监控搭建

1:增加javamelody依赖
<dependency>
    <groupId>net.bull.javamelody</groupId>
    <artifactId>javamelody-core</artifactId>
    <version>1.57.0</version>
</dependency>


2:web.xml配置增加
<listener>
    <listener-class>net.bull.javamelody.SessionListener</listener-class>
</listener>     
<filter>
    <filter-name>monitoring</filter-name>
    <filter-class>net.bull.javamelody.MonitoringFilter</filter-class>
</filter>
<filter-mapping>
    <filter-name>monitoring</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>



3:监控sql数据源增加bean配置

<bean id="javamelodyDataSourceBeanPostProcessor" class="net.bull.javamelody.SpringDataSourceBeanPostProcessor"/>

通过查看源代码看到,是通过spring的BeanPostProcessor扩展点增加动态代理实现sql监控

4:注意如果应用使用logback打印日志,请升级slf4j相关依赖到最新1.7.12版本。
因为log4j-over-slf4j 1.7.7版本缺少方法:
void org.apache.log4j.AppenderSkeleton.setThreshold(Priority threshold);

升级后,相关依赖版本如下:
<dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-api</artifactId>
    <version>1.7.12</version>
</dependency>
<dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>jcl-over-slf4j</artifactId>
    <version>1.7.12</version>
</dependency>
<dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>log4j-over-slf4j</artifactId>
    <version>1.7.12</version>
</dependency>


5:应用监控链接
http://应用ip地址:端口/部署上下文/monitoring

你可能感兴趣的:(javamelody应用监控搭建)