How to use a Windows filename with a colon with Java 9 unified logging?

末鹿安然 提交于 2021-02-04 18:53:28

问题


% java11 -Xlog:gc*:file=c:\max.txt -version
[0.002s][error][logging] Invalid decorator '\max.txt'.
Invalid -Xlog option '-Xlog:gc*:file=c:\max.txt', see error log for 
details.
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.

Apparently with Java 9 (and later) unified logging a colon is used as a separator between fields in the -Xlog arguments. So, how do I specify a Windows pathname that has a colon in it? Is there an escape of some kind? If I specify the filename as is, I get the error I included above. Thank you.


回答1:


One of the ways suggested for solving that on the mailing list is using shell escapes like:

java -Xlog:gc*:file=\"C:\max.txt\" -version

Note that according to Dave Holmes' posting, only double quotes are supported. Depending on the shell, the escaping is necessary so that the Java command sees the quotes.



来源:https://stackoverflow.com/questions/52955773/how-to-use-a-windows-filename-with-a-colon-with-java-9-unified-logging

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!