如何在Java 9统一日志记录中使用带冒号的Windows文件名? [英] How to use a Windows filename with a colon with Java 9 unified logging?

查看:74
本文介绍了如何在Java 9统一日志记录中使用带冒号的Windows文件名?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

% 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路径名?是否有某种逃生方法?如果按原样指定文件名,则会收到上面包含的错误.谢谢.

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.

推荐答案

为解决 使用的是shell转义,例如:

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

请注意,根据Dave Holmes的帖子,仅支持双引号.根据外壳的不同,转义是必需的,以便Java命令可以看到引号.

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.

这篇关于如何在Java 9统一日志记录中使用带冒号的Windows文件名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆