-Xlog,..,file=filename with absolute path on windows?
david.holmes at oracle.com
Mon Aug 21 01:19:51 UTC 2017
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 detected:
> set GC_LOG_OPTS="-Xlog:gc*:file=!SOLR_LOGS_DIR!\solr_gc.log:time,uptime:filecount=9,filesize=20000"
> 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 Schindler\Projects\lucene\trunk-lusolr1\solr\server\logs\solr_gc.log:time,uptime:filecount=9,filesize=20000'
> 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 bummer?
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.
> Uwe Schindler
> uschindler at apache.org
> ASF Member, Apache Lucene PMC / Committer
> Bremen, Germany
More information about the hotspot-dev