You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by MrVJTod <Mr...@gmail.com> on 2012/10/08 17:17:33 UTC
gc log filename variables in windows
In linux/solaris, I can specify
-Xloggc:/my/logs/sourcecode-gc-${NOW}.log
And get a logfile named as such
/my/logs/sourcecode-gc-1008-0938.log
with the last time of startup as past of the log filename
But if I try to do something similar in Windows
-Xloggc:c:\my\logs\sourcecode-gc-${NOW}.log
I get a logfile named
c:\my\logs\sourcecode-gc-${NOW}.log
with the variable text as past of the log filename
Does tomcat on Windows not support variables in the GC filename?
I've tried a dozen different combinations
$DATE // ${%DATE%} // $[%DATE%] // $(%DATE%)
${DATE} // $[DATE] // $(DATE) // $DATE // %DATE // %NOW%
`%DATE%` // '%DATE%' // `cmd /c now /t` // 'cmd /c now /t'
%Y // %YYYY
and several other iterations
but the logfilename contains the variable that I was hoping would be
replaced with a timestamp.
and I can't seem to find a solid reference for Windows GC log filenames.
--
View this message in context: http://tomcat.10.n6.nabble.com/gc-log-filename-variables-in-windows-tp4987672.html
Sent from the Tomcat - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: gc log filename variables in windows
Posted by MrVJTod <Mr...@gmail.com>.
I understand. NOW, in my linux environment is set via a shell script in the
tomcat settings file as part of startup.
NOW=`date +"%m%d-%H%M"`
I wasn't thinking of the startup script like that.
I'll be moving on. Thanks.
--
View this message in context: http://tomcat.10.n6.nabble.com/gc-log-filename-variables-in-windows-tp4987672p4987677.html
Sent from the Tomcat - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: gc log filename variables in windows
Posted by André Warnier <aw...@ice-sa.com>.
MrVJTod wrote:
> In linux/solaris, I can specify
> -Xloggc:/my/logs/sourcecode-gc-${NOW}.log
> And get a logfile named as such
> /my/logs/sourcecode-gc-1008-0938.log
> with the last time of startup as past of the log filename
>
> But if I try to do something similar in Windows
> -Xloggc:c:\my\logs\sourcecode-gc-${NOW}.log
> I get a logfile named
> c:\my\logs\sourcecode-gc-${NOW}.log
> with the variable text as past of the log filename
>
> Does tomcat on Windows not support variables in the GC filename?
> I've tried a dozen different combinations
> $DATE // ${%DATE%} // $[%DATE%] // $(%DATE%)
> ${DATE} // $[DATE] // $(DATE) // $DATE // %DATE // %NOW%
> `%DATE%` // '%DATE%' // `cmd /c now /t` // 'cmd /c now /t'
> %Y // %YYYY
> and several other iterations
> but the logfilename contains the variable that I was hoping would be
> replaced with a timestamp.
>
> and I can't seem to find a solid reference for Windows GC log filenames.
>
>
Hi.
1) That's not really a Tomcat question, it's a Java JVM question.
So the question "Does tomcat on Windows not support variables in the GC filename?" is
mis-directed. The "-Xloggc" is not a Tomcat parameter, it is a JVM parameter, interpreted
by the JVM which runs Tomcat. Get the difference ?
2) Under Linux, where is the "NOW" variable set ? (probably in a Tomcat startup shell
script, right ?)
3) How do you start (the JVM which runs) Tomcat under Windows ?
(If it is started as a Windows Service, it doesn't really have a Linux-like shell. It -
or rather the "service wrapper" (which runs the JVM which runs Tomcat) - takes its
parameters from the Windows Registry, not the command-line. No shell = no shell variables
= no "NOW").
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: [speculative] gc log filename variables in windows
Posted by André Warnier <aw...@ice-sa.com>.
MrVJTod wrote:
> and I'm not going to convert my few remaining windows JVMs to use batch files
> instead of running as a service.
>
> this is just extra motivation to get these last windows JVMs converted to
> *nix.
>
I basically agree, and this is thus just a bit of intellectual musing :
In the Registry of my Windows XP laptop, under
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tomcat6, I see an "ImagePath" with a
value "C:\apache-tomcat-6.0.24\bin\tomcat6.exe //RS//Tomcat6".
(tomcat6.exe being this "service wrapper" I was mentioning before : it provides the
necessary wrapping to act as a Windows Service, and actually runs the JVM that runs Tomcat).
It may be possible to change this ImagePath to run a Windows .CMD file which would set the
appropriate "NOW" variable and then run the above wrapper .exe.
And then, using tomcat6w.exe (the GUI registry editor which allows to set the environment
which the wrapper passes to the JVM it runs), set a Java option including a reference to
%NOW%.
If pigs can fly (and it seems that in some countries many people think they can - see
http://planetsave.com/2011/03/28/can-pigs-fly/), it may even work.
Or, rather than playing around modifying things in the Registry, how about :
- create a user to run the Tomcat Service, and modify the Tomcat Service to run as that
user (rather than as "LocalSystem")
- give that user a "logon script"
- set the NOW variable in the logon script of that user
Windows may call that script whenever it starts the Tomcat Service.
Again, just idle speculation but hey, this is a Tomcat list, not a Windows one.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: gc log filename variables in windows
Posted by MrVJTod <Mr...@gmail.com>.
and I'm not going to convert my few remaining windows JVMs to use batch files
instead of running as a service.
this is just extra motivation to get these last windows JVMs converted to
*nix.
--
View this message in context: http://tomcat.10.n6.nabble.com/gc-log-filename-variables-in-windows-tp4987672p4987679.html
Sent from the Tomcat - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: gc log filename variables in windows
Posted by MrVJTod <Mr...@gmail.com>.
windows command line isn't good at short code, but I've used this to rename
window log files on occasion
the first section parses the YYYYMMDD out of %DATE%
and the second section removes the colon/period/spaces out of %TIME% and
then trims the resulting string to just the first 4 characters HHMM.
if run from {something.bat)
REM ## BEGIN SCRIPT FILE
FOR %%A IN (%Date%) DO (
FOR /F "tokens=1-3 delims=/-" %%B in ("%%~A") DO (
SET Today=%%D%%B%%C
)
)
SET RightNow=%Time::=%
SET RightNow=%RightNow:.=%
SET RightNow=%RightNow: =%
SET RightNow=%RightNow:~0,4%
SET fileStamp=%TODAY%.%RIGHTNOW%
REM ## END SCRIPT FILE
which would result something like this
20121008.1506
which could be used in a batch to rename files with a timestamp
rename file.txt file.%timestamp%.txt
--
View this message in context: http://tomcat.10.n6.nabble.com/gc-log-filename-variables-in-windows-tp4987672p4987678.html
Sent from the Tomcat - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: gc log filename variables in windows
Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
To whom it may concern,
On 10/8/12 11:17 AM, MrVJTod wrote:
> In linux/solaris, I can specify
> -Xloggc:/my/logs/sourcecode-gc-${NOW}.log And get a logfile named
> as such /my/logs/sourcecode-gc-1008-0938.log with the last time of
> startup as past of the log filename
>
> But if I try to do something similar in Windows
> -Xloggc:c:\my\logs\sourcecode-gc-${NOW}.log I get a logfile named
> c:\my\logs\sourcecode-gc-${NOW}.log with the variable text as past
> of the log filename
>
> Does tomcat on Windows not support variables in the GC filename?
> I've tried a dozen different combinations $DATE // ${%DATE%}
> // $[%DATE%] // $(%DATE%) ${DATE} // $[DATE] // $(DATE) //
> $DATE // %DATE // %NOW% `%DATE%` // '%DATE%' // `cmd /c now
> /t` // 'cmd /c now /t' %Y // %YYYY and several other
> iterations but the logfilename contains the variable that I was
> hoping would be replaced with a timestamp.
>
> and I can't seem to find a solid reference for Windows GC log
> filenames.
This has nothing to do with GC filenames and everything to do with the
way cmd.exe does variable replacement.
First of all, cmd.exe does not recognize backtics (``) as meaningful
in any way, so that's not going to work. Second, sh-style $varname
doesn't work either.
cmd.exe (and every version of MS-DOS CLI before it) has always used
%varname% for variable replacement.
Lastly, the variable has to have a value. If you haven't set a value
for the DATE variable, then it will give you nothing. (Okay, I'm
floored: 'echo %DATE%' in cmd.exe actually gives you the current date
- "Mon 10/08/2012" for me. That seems to be ringing a bell from back
in my MS-DOS days, but the value you get isn't very friendly: it's got
a space and it's localized for the current user: stupid American date
formatting.)
I'm not sure what the best way to get the current date in an
environment variable is. win32's "date" command totally sucks: you
can't tell it how to format the date. You also can't use
command-substitution (back ticks) to get the output from a program -
you could write one to get the proper date format - into an
environment variable. Child processes can't modify the environment of
the parent.
I think this is why people end up writing hideout scripts for win32
that do things like create another script on-the-fly and do
string-replacement directly on the script, then run it.
If you have your date in a variable, like 'NOW', then you ought to be
able to use "c:\my\logs\sourcecode-gc-%NOW%.log". Of course, that will
only work if you are launching Tomcat from the command-line and not if
you are running as a service.
- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Mozilla - http://www.enigmail.net/
iEYEARECAAYFAlBzHxMACgkQ9CaO5/Lv0PCJugCguC9GXRauvUyjjVOtuXO2mmuK
iDUAnj/YxvmDZWEvYZnwBGFgOAHjd5EN
=/dAU
-----END PGP SIGNATURE-----
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org