-Xlog,..,file=filename with absolute path on windows?
uschindler at apache.org
Mon Aug 21 06:07:07 UTC 2017
> Hi Uwe,
> On 21/08/2017 5:55 AM, Uwe Schindler wrote:
> > Hi,
> > 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:
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.
Finally: Who parses what (cmd.exe, Windows ShellExecute, java)? If anybody knows he/she might explain.
More information about the hotspot-dev