jconsole 重定向输出日志到文件

jconsole redirect output log to file

如何在日志文件中保存 jconsole 输出?

我尝试添加 logging.properties 但它已被忽略:

jconsole.exe -Jjava.util.logging.config.file=logging.properties -debug

或者

jconsole.exe -Djava.util.logging.config.file=logging.properties -debug

目前我得到的 Jconsole 输出 window 最小日志为:

java.lang.SecurityException: Expecting a javax.rmi.ssl.SslRMIClientSocketFactory RMI client socket factory in stub!
    at javax.management.remote.rmi.RMIConnector.checkStub(RMIConnector.java:1875)
    at javax.management.remote.rmi.RMIConnector.connect(RMIConnector.java:295)
    at javax.management.remote.JMXConnectorFactory.connect(JMXConnectorFactory.java:270)
    at sun.tools.jconsole.ProxyClient.tryConnect(ProxyClient.java:357)
    at sun.tools.jconsole.ProxyClient.connect(ProxyClient.java:313)
    at sun.tools.jconsole.VMPanel.run(VMPanel.java:294)
sorting table against column=0 ascending=true
sorting table against column=0 ascending=true
sorting table against column=0 ascending=true

我也有抑制的选项,但我不想

Use '--console suppress' to suppress console output.

要启动 jvisualvm 并登录到一个文件,您可以创建一个 logging.properties 文件

.level= FINER
handlers= java.util.logging.FileHandler
java.util.logging.FileHandler.pattern = jvisualvm.log
java.util.logging.FileHandler.formatter = java.util.logging.SimpleFormatter

并开始 jvisualvm 作为

    jvisualvm -J-Djava.util.logging.config.file=logging.properties