I've got a Java Application running against Apache Tomcat, under Windows. There are two ways of running this application - either as a Windows Service, or from a batch file to invoke Tomcat manually.
When I start the application via the batch file, I use the following to add GC logs to the JVM parameters:
-Xloggc=%~dp0..\logs\gc-%DATE:~-4%.%DATE:~4,2%.%DATE:~7,2%_%TIME:~0,2%.%TIME:~3,2%.%TIME:~6,2%.log
That causes the GC logs to be output with the date in the file name - but when run as a service, the DATE
and TIME
variables do not resolve correctly.
When using a Windows Service, what variables must I use in my JVM parameters to ensure the date and time are appended to the GC logs?
I have tried to simplify it - gc-%DATE%.log, gc-${DATE}.log
, in all cases the variable will not resolve.
Any help is appreciated!
Edit: Please note that any solution must work when the application runs as a Windows Service. Stand alone is fine, we've got that covered. It's only when a Windows Service is used.