Question

I need to monitor java application and I am using javamelody.

But the problem is, I have to get the data that javamelody has so I can show it in another screen. I know that javamelody store its rdd files in temp/javamelody directory, now I need to change the storage-directory to another path so I can get the data from that path.

How can I set the storage-directory of javamelody?

Was it helpful?

Solution

Oh I think I've found the answer I just have to set command line or xml file in my tomcat like this

<?xml version="1.0" encoding="UTF-8" ?>
<Context docBase="pathto\appname.war" path="javamelody" reloadable="false" >
        <Parameter name='javamelody.storage-directory' value='pathname' override='false'/>
</Context>

Thank you for the help :D

OTHER TIPS

In web.xml, define filter javamelody with parameter storage-directory as below:

<filter>
    <filter-name>javamelody</filter-name>
    <filter-class>net.bull.javamelody.MonitoringFilter</filter-class>
    <init-param>
        <param-name>storage-directory</param-name>
        <param-value>/path/to/the/storage/directory</param-value>
    </init-param>
</filter>

I tested using JavaMelody version 1.60.0. For more information refer to the JavaMelody user guide.

for javamelody-spring-boot-starter

 javamelody.init-parameters.storage-directory=/tmp/javamelody-${spring.application.name}

For Spring Boot

public class JavaMelodyConfiguration implements ServletContextInitializer {

@Value(value="${javamelody.storage-directory}")
String jmStorageDir;

@Override
public void onStartup(ServletContext servletContext) throws ServletException {
    servletContext.addListener(new SessionListener());
    servletContext.setInitParameter("javamelody.storage-directory", jmStorageDir);
}

then you can set the javamelody.storage-directory in application.properties

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top