Change the storage-directory of javamelody
Asked Answered
P

4

5

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?

Peeve answered 12/6, 2013 at 7:36 Comment(7)
java -Djava.io.tmpdir=/new/tmp yourjar (on Linux) or setting %TMP% (on Windows) should do the trick.Variate
the command can only be used for the project which has main class. javamelody is a library and it doesn't have any main class. How can the command used for the library class which has no main class?Peeve
Hah, even better: code.google.com/p/javamelody/wiki/UserGuide and scroll to storage-directory, this looks like what you want.Variate
I have seen it but it doesn't provide any statement about how to do itPeeve
Right in the beginning of section 6, e.g. -Djavamelody.storage-directory=/some/dir.Variate
Where should I type that command? I type it in javamelody temp directory and it gave me exceptionPeeve
This is not a command but a command option; you could set it anywhere where the startup options are set (e.g. startup script, tomcat properties file, etc). What kind of application do you have? Is it a servlet? What servlet container do you use in this case?Variate
P
5

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

Peeve answered 13/6, 2013 at 5:46 Comment(1)
In this case it is called "context parameter" (which is set in context.xml file), not the command-line option :) Glad you've managed, cheers ;)Variate
N
2

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.

Nobel answered 2/8, 2016 at 13:53 Comment(0)
F
1

for javamelody-spring-boot-starter

 javamelody.init-parameters.storage-directory=/tmp/javamelody-${spring.application.name}
Frith answered 20/1, 2021 at 19:12 Comment(0)
E
-1

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

Eskimoaleut answered 30/6, 2016 at 18:54 Comment(1)
This is not the right way to integrate javamelody in Spring boot, neither to set javamelody parameters. See github.com/javamelody/javamelody/wiki/SpringBootStarterStomatic

© 2022 - 2024 — McMap. All rights reserved.