-Xlog,..,file=filename with absolute path on windows?
david.holmes at oracle.com
Mon Aug 21 06:54:40 UTC 2017
On 21/08/2017 4:07 PM, Uwe Schindler wrote:
> Hi David,
>> Hi Uwe,
>> On 21/08/2017 5:55 AM, Uwe Schindler wrote:
>>> I am currently adapting Apache Solr's startup scripts for Java 9. Linux was
>> already done at the beginning of this year and works perfectly, but Windows
>> brings some problems. I already fixed version number parsing, but I
>> stumbled on the following: In the Windows ".cmd" shell script it uses the
>> following to enable Garbage collection logging to a separate file, if Java 9 is
>>> set GC_LOG_OPTS="-
>>> The problem is now that "!SOLR_LOGS_DIR!" is already expanded to an
>> absolute Windows Path by the shell and therefore starts with "C:\". The
>> problem is now the colon, which breaks the log parsing. When Java 9 starts it
>> exits with the following parsing error:
>>> Invalid -Xlog option '-Xlog:gc*:file=C:\Users\Uwe
>>> If I replace with a simple file name, without path/drive letter it works. How
>> to escape the colon in the drive letter correctly, to me this looks like a
>> You can fix this by quoting the filename, with shell escapes eg:
>> java -Xlog:gc*:file=\"C:\solr_gc.log\":time,uptime:filecount=9 -version
>> Doing that within an env var may be a bit trickier.
> This approach worked quite easy. As Windows shell does not additionally handle quote escaping, so it seems to be passed as is to Java:
> set GC_LOG_OPTS="-Xlog:gc*:file=\"!SOLR_LOGS_DIR!\solr_gc.log\":time,uptime:filecount=9,filesize=20000"
> I was not aware that Java's command line parser does some escaping logic on its own, so I have no explanation what really happens internally, but this helps (at least on windows, where filenames may contain colons).
> It would be good to add this to the documentation, because there is nothing about escaping file names with spaces or colons. Spaces is no problem, if you add shell quoted around the whole arg (see above), as you should always do on all platforms, but the colon is tricky.
I agree. Not sure if this was discussed when the unified logging system
> Finally: Who parses what (cmd.exe, Windows ShellExecute, java)? If anybody knows he/she might explain.
Some parsing happens at each level - hence need to quote args with
spaces at the shell-level, or to use \ escapes.
The -Xlog is passed through to the JVM from the launcher. It is the
logging subsystem that allows for values to be quoted e.g x=y or x="y"
But only double-quote quoting is supported.
More information about the hotspot-dev