如何在 Java 9 统一日志记录中使用带冒号的 Windows 文件名?
How to use a Windows filename with a colon with Java 9 unified logging?
% 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.
显然,对于 Java 9(及更高版本)统一日志记录,冒号用作 -Xlog
参数中字段之间的分隔符。那么,如何指定其中包含冒号的 Windows 路径名?有某种逃避吗?如果我按原样指定文件名,则会收到上面包含的错误。谢谢。
建议解决 on the mailing list 的方法之一是使用 shell 转义,例如:
java -Xlog:gc*:file=\"C:\max.txt\" -version
请注意,根据 Dave Holmes 的帖子,仅支持双引号。根据 shell,转义是必要的,这样 Java 命令才能看到引号。
% 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.
显然,对于 Java 9(及更高版本)统一日志记录,冒号用作 -Xlog
参数中字段之间的分隔符。那么,如何指定其中包含冒号的 Windows 路径名?有某种逃避吗?如果我按原样指定文件名,则会收到上面包含的错误。谢谢。
建议解决 on the mailing list 的方法之一是使用 shell 转义,例如:
java -Xlog:gc*:file=\"C:\max.txt\" -version
请注意,根据 Dave Holmes 的帖子,仅支持双引号。根据 shell,转义是必要的,这样 Java 命令才能看到引号。