javamelody - 存储文件总是在 tomcat 的临时文件夹的相对路径中

javamelody - storage files always in relative path to temp folder of tomcat

我正在使用 javamelody 在 tomcat8 中监视我的应用程序。 context.xml 的定义如下:

<Context path="/foo" docBase="foo.war" reloadable="false">
    <Parameter name='javamelody.storage-directory' value='/srv/data/foo/javamelody' override='false'/>
    <Parameter name='javamelody.log' value='true' override='false'/>
</Context>

根据 javamelody 的文档:

The parameter storage-directory is the name of the directory of storage (javamelody by default). If the name of the directory starts with '/' (or on Windows, with drive specifier followed by '', or if its prefix is "\"), it is considered as an absolute path, otherwise it is considered as relative to the temporary directory ( in TOMCAT_HOME for tomcat).

但是没有用。我总是降落在:

<WINDOWS-PATH>\apache-tomcat-8.5.34\temp\srv\data\foo\javamelody\foo_HOSTNAME

我也试过这样的值:

但它总是在 tomcat

的 /temp 文件夹中

Javamelody 版本:1.82.0

这部分文档中存在转义问题。 它现在说:

The parameter storage-directory is the name of the directory of storage (javamelody by default). If the name of the directory starts with '/' (or on Windows, with drive specifier followed by '\', or if its prefix is "\"), it is considered as an absolute path, otherwise it is considered as relative to the temporary directory

所以你可以在你的上下文中写:

<Context path="/foo" docBase="foo.war" reloadable="false">
    <Parameter name='javamelody.storage-directory' value='c:\srv\data\foo\javamelody' override='false'/>
    <Parameter name='javamelody.log' value='true' override='false'/>
</Context>