Re: AW: Maybe a stupid (Windows related) question

2022-03-24 Thread Rony G. Flatscher (Apache)
Hi Konstantin,

On 23.03.2022 23:29, Konstantin Kolinko wrote:
> ср, 23 мар. 2022 г. в 14:12, Rony G. Flatscher (Apache) :
>> skip...
>>
>> startup.bat uses start to run catalina.bat in a new cmd window with:
>>
>> call "%EXECUTABLE%" start %CMD_LINE_ARGS%
>>
>> catalina.bat then starts Tomcat as:
>>
>> %_EXECJAVA% %CATALINA_LOGGING_CONFIG% %LOGGING_MANAGER% %JAVA_OPTS% 
>> %CATALINA_OPTS% %DEBUG_OPTS%
>> -D%ENDORSED_PROP%="%JAVA_ENDORSED_DIRS%" -classpath "%CLASSPATH%"
>> -Dcatalina.base="%CATALINA_BASE%" -Dcatalina.home="%CATALINA_HOME%"
>> -Djava.io.tmpdir="%CATALINA_TMPDIR%" %MAINCLASS% %CMD_LINE_ARGS% 2>&1 1>
>> D:\orx.debug\work_rii_tomcat\test.log
>>
>> This does not work.
> (It does not matter, but you somehow lost "%ACTION%" at the end of the
> above line.)
>
> If I prefix the above line with "echo" to see what command is being
> executed, like this:
>
> echo %_EXECJAVA% %CATALINA_LOGGING_CONFIG% %LOGGING_MANAGER%
> %JAVA_OPTS% %CATALINA_OPTS% %DEBUG_OPTS%
> -D%ENDORSED_PROP%="%JAVA_ENDORSED_DIRS%" -classpath "%CLASSPATH%"
> -Dcatalina.base="%CATALINA_BASE%" -Dcatalina.home="%CATALINA_HOME%"
> -Djava.io.tmpdir="%CATALINA_TMPDIR%" %MAINCLASS% %CMD_LINE_ARGS%
> %ACTION% 1>>mylog.txt 2>&1
>
> then I get the following results:
>
> a) After calling "startup.bat" or "catalina.bat start" I see the
> following in mylog.txt:
>
> start "Tomcat" "C:\pathtojava\java.exe" .
> org.apache.catalina.startup.Bootstrap start
>
> b) After calling "catalina.bat run" I see the following:
>
> "C:\pathtojava\java.exe" . org.apache.catalina.startup.Bootstrap start
>
> Note the difference.
>
> It is the "start" command that creates a new window.  The "call"
> command that you mentioned is just a command to execute a different
> batch file and return to continue executing the original batch file.
>
> BTW, commands "help start" and "help call" print some reference for
> those commands.
>
>
> Looking at the reference for "start", I think your only option is to
> use "catalina.bat run" to start Tomcat. When I do so, the redirection
> works as expected.
>
>
> The following also works, without any modifications to the catalina.bat file:
>
> catalina.bat run 1>>mylog.txt 2>&1
>
> or with remote debugging being enabled:
>
> catalina.bat jpda run 1>>mylog.txt 2>&1

thank you very much for your information and explanations which solves this, 
many thanks!

(Was not aware of "catalina.bat run" and the like, adding to that your 
step-by-step explanations
made it a breeze to get this up and running as a result!)

Kudos!

---rony



-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: AW: Maybe a stupid (Windows related) question

2022-03-23 Thread Konstantin Kolinko
ср, 23 мар. 2022 г. в 14:12, Rony G. Flatscher (Apache) :
>
> skip...
>
> startup.bat uses start to run catalina.bat in a new cmd window with:
>
> call "%EXECUTABLE%" start %CMD_LINE_ARGS%
>
> catalina.bat then starts Tomcat as:
>
> %_EXECJAVA% %CATALINA_LOGGING_CONFIG% %LOGGING_MANAGER% %JAVA_OPTS% 
> %CATALINA_OPTS% %DEBUG_OPTS%
> -D%ENDORSED_PROP%="%JAVA_ENDORSED_DIRS%" -classpath "%CLASSPATH%"
> -Dcatalina.base="%CATALINA_BASE%" -Dcatalina.home="%CATALINA_HOME%"
> -Djava.io.tmpdir="%CATALINA_TMPDIR%" %MAINCLASS% %CMD_LINE_ARGS% 2>&1 1>
> D:\orx.debug\work_rii_tomcat\test.log
>
> This does not work.

(It does not matter, but you somehow lost "%ACTION%" at the end of the
above line.)

If I prefix the above line with "echo" to see what command is being
executed, like this:

echo %_EXECJAVA% %CATALINA_LOGGING_CONFIG% %LOGGING_MANAGER%
%JAVA_OPTS% %CATALINA_OPTS% %DEBUG_OPTS%
-D%ENDORSED_PROP%="%JAVA_ENDORSED_DIRS%" -classpath "%CLASSPATH%"
-Dcatalina.base="%CATALINA_BASE%" -Dcatalina.home="%CATALINA_HOME%"
-Djava.io.tmpdir="%CATALINA_TMPDIR%" %MAINCLASS% %CMD_LINE_ARGS%
%ACTION% 1>>mylog.txt 2>&1

then I get the following results:

a) After calling "startup.bat" or "catalina.bat start" I see the
following in mylog.txt:

start "Tomcat" "C:\pathtojava\java.exe" .
org.apache.catalina.startup.Bootstrap start

b) After calling "catalina.bat run" I see the following:

"C:\pathtojava\java.exe" . org.apache.catalina.startup.Bootstrap start

Note the difference.

It is the "start" command that creates a new window.  The "call"
command that you mentioned is just a command to execute a different
batch file and return to continue executing the original batch file.

BTW, commands "help start" and "help call" print some reference for
those commands.


Looking at the reference for "start", I think your only option is to
use "catalina.bat run" to start Tomcat. When I do so, the redirection
works as expected.


The following also works, without any modifications to the catalina.bat file:

catalina.bat run 1>>mylog.txt 2>&1

or with remote debugging being enabled:

catalina.bat jpda run 1>>mylog.txt 2>&1

Best regards,
Konstantin Kolinko

-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: AW: Maybe a stupid (Windows related) question

2022-03-23 Thread Rony G. Flatscher (Apache)
On 23.03.2022 18:21, EXT-Denton, Sam T wrote:
> I believe that "2>&1 1>D:\orx.debug\work_rii_tomcat\test.log" will first 
> redirect stderr to stdout, and then redirect stdout to the file, leaving 
> stderr pointing to the original stdout, which is presumably the terminal.
>
> Try "1>D:\orx.debug\work_rii_tomcat\test.log 2>&1"

Thank you, this does not change the behaviour.

---rony


>
>
> -Original Message-
> From: Rony G. Flatscher (Apache)  
> Sent: Wednesday, March 23, 2022 6:12 AM
> To: users@tomcat.apache.org
> Subject: Re: AW: Maybe a stupid (Windows related) question
>
> On 23.03.2022 11:45, Thomas Hoffmann (Speed4Trade GmbH) wrote:
>>> -Ursprüngliche Nachricht-
>>> Von: Rony G. Flatscher (Apache) 
>>> Gesendet: Mittwoch, 23. März 2022 11:34
>>> An: users@tomcat.apache.org
>>> Betreff: Re: Maybe a stupid (Windows related) question
>>>
>>> On 22.03.2022 20:18, Christopher Schultz wrote:
>>>
>>> ... cut ...
>>>
>>>> You still can't really "background" the process the way you can on
>>>> *nix. Sure, you can get your command-prompt back, but if you kill
>>>> cmd.exe, so does your child process die. And if you log out, that process
>>> dies as well.
>>>
>>> The problem is different: redirecting stderr and stdout does not redirect in
>>> this scenario (employing %CATALINA_HOME%\bin\startup.bat), rather
>>> output statements to stderr
>>> (System.err.println(...)) and stdout (System.out.println(...)) gets still
>>> displayed in the Tomcat window.
>>>
>>> This involves (at least in my experiments) editing bin\startup.bat and/or
>>> bin\catalina.bat which should not be necessary if understanding Tomcat's
>>> philsophy correctly. If adjustments are necessary it is advised to supply a
>>> "bin\setup.bat" script to do so.
>>>
>>> So what I would be looking for is either a configuration change or an
>>> environment variable to set which allows redirecting stdout and stderr to
>>> appropriate log files as is done with the service version by default.
>>>
>>>> Using the Windows Service is really the best way to do it on Windows.
>>> The use case is testing Tomcat 10 in various ways, including running it in
>>> debug mode and attaching via IntelliJ for inspection.
>>>
>>> ---rony
>>>
>>> -
>>> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
>>> For additional commands, e-mail: users-h...@tomcat.apache.org
>> The bat-file uses the line:
>> call "%EXECUTABLE%" start %CMD_LINE_ARGS%
>>
>> At this place you might be able to redirect the output:
>> call "%EXECUTABLE%" start %CMD_LINE_ARGS%  > out.log
>>
>> You could also try to pass the redirect param to the argument of 
>> startup.bat, don’t know if this works, e.g.
>> startup.bat " > out.log"
> startup.bat uses start to run catalina.bat in a new cmd window with:
>
> call "%EXECUTABLE%" start %CMD_LINE_ARGS%
>
> catalina.bat then starts Tomcat as:
>
> %_EXECJAVA% %CATALINA_LOGGING_CONFIG% %LOGGING_MANAGER% %JAVA_OPTS% 
> %CATALINA_OPTS% %DEBUG_OPTS%
> -D%ENDORSED_PROP%="%JAVA_ENDORSED_DIRS%" -classpath "%CLASSPATH%"
> -Dcatalina.base="%CATALINA_BASE%" -Dcatalina.home="%CATALINA_HOME%"
> -Djava.io.tmpdir="%CATALINA_TMPDIR%" %MAINCLASS% %CMD_LINE_ARGS% 2>&1 1>
> D:\orx.debug\work_rii_tomcat\test.log
>
> This does not work.
>
> ---rony
>
>

-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



RE: AW: Maybe a stupid (Windows related) question

2022-03-23 Thread EXT-Denton, Sam T
I believe that "2>&1 1>D:\orx.debug\work_rii_tomcat\test.log" will first 
redirect stderr to stdout, and then redirect stdout to the file, leaving stderr 
pointing to the original stdout, which is presumably the terminal.

Try "1>D:\orx.debug\work_rii_tomcat\test.log 2>&1"


-Original Message-
From: Rony G. Flatscher (Apache)  
Sent: Wednesday, March 23, 2022 6:12 AM
To: users@tomcat.apache.org
Subject: Re: AW: Maybe a stupid (Windows related) question

On 23.03.2022 11:45, Thomas Hoffmann (Speed4Trade GmbH) wrote:
>> -Ursprüngliche Nachricht-
>> Von: Rony G. Flatscher (Apache) 
>> Gesendet: Mittwoch, 23. März 2022 11:34
>> An: users@tomcat.apache.org
>> Betreff: Re: Maybe a stupid (Windows related) question
>>
>> On 22.03.2022 20:18, Christopher Schultz wrote:
>>
>> ... cut ...
>>
>>> You still can't really "background" the process the way you can on
>>> *nix. Sure, you can get your command-prompt back, but if you kill
>>> cmd.exe, so does your child process die. And if you log out, that process
>> dies as well.
>>
>> The problem is different: redirecting stderr and stdout does not redirect in
>> this scenario (employing %CATALINA_HOME%\bin\startup.bat), rather
>> output statements to stderr
>> (System.err.println(...)) and stdout (System.out.println(...)) gets still
>> displayed in the Tomcat window.
>>
>> This involves (at least in my experiments) editing bin\startup.bat and/or
>> bin\catalina.bat which should not be necessary if understanding Tomcat's
>> philsophy correctly. If adjustments are necessary it is advised to supply a
>> "bin\setup.bat" script to do so.
>>
>> So what I would be looking for is either a configuration change or an
>> environment variable to set which allows redirecting stdout and stderr to
>> appropriate log files as is done with the service version by default.
>>
>>> Using the Windows Service is really the best way to do it on Windows.
>> The use case is testing Tomcat 10 in various ways, including running it in
>> debug mode and attaching via IntelliJ for inspection.
>>
>> ---rony
>>
>> -
>> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
>> For additional commands, e-mail: users-h...@tomcat.apache.org
> The bat-file uses the line:
> call "%EXECUTABLE%" start %CMD_LINE_ARGS%
>
> At this place you might be able to redirect the output:
> call "%EXECUTABLE%" start %CMD_LINE_ARGS%  > out.log
>
> You could also try to pass the redirect param to the argument of startup.bat, 
> don’t know if this works, e.g.
> startup.bat " > out.log"

startup.bat uses start to run catalina.bat in a new cmd window with:

call "%EXECUTABLE%" start %CMD_LINE_ARGS%

catalina.bat then starts Tomcat as:

%_EXECJAVA% %CATALINA_LOGGING_CONFIG% %LOGGING_MANAGER% %JAVA_OPTS% 
%CATALINA_OPTS% %DEBUG_OPTS%
-D%ENDORSED_PROP%="%JAVA_ENDORSED_DIRS%" -classpath "%CLASSPATH%"
-Dcatalina.base="%CATALINA_BASE%" -Dcatalina.home="%CATALINA_HOME%"
-Djava.io.tmpdir="%CATALINA_TMPDIR%" %MAINCLASS% %CMD_LINE_ARGS% 2>&1 1>
D:\orx.debug\work_rii_tomcat\test.log

This does not work.

---rony



-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: AW: Maybe a stupid (Windows related) question

2022-03-23 Thread Rony G. Flatscher (Apache)
On 23.03.2022 11:45, Thomas Hoffmann (Speed4Trade GmbH) wrote:
>> -Ursprüngliche Nachricht-
>> Von: Rony G. Flatscher (Apache) 
>> Gesendet: Mittwoch, 23. März 2022 11:34
>> An: users@tomcat.apache.org
>> Betreff: Re: Maybe a stupid (Windows related) question
>>
>> On 22.03.2022 20:18, Christopher Schultz wrote:
>>
>> ... cut ...
>>
>>> You still can't really "background" the process the way you can on
>>> *nix. Sure, you can get your command-prompt back, but if you kill
>>> cmd.exe, so does your child process die. And if you log out, that process
>> dies as well.
>>
>> The problem is different: redirecting stderr and stdout does not redirect in
>> this scenario (employing %CATALINA_HOME%\bin\startup.bat), rather
>> output statements to stderr
>> (System.err.println(...)) and stdout (System.out.println(...)) gets still
>> displayed in the Tomcat window.
>>
>> This involves (at least in my experiments) editing bin\startup.bat and/or
>> bin\catalina.bat which should not be necessary if understanding Tomcat's
>> philsophy correctly. If adjustments are necessary it is advised to supply a
>> "bin\setup.bat" script to do so.
>>
>> So what I would be looking for is either a configuration change or an
>> environment variable to set which allows redirecting stdout and stderr to
>> appropriate log files as is done with the service version by default.
>>
>>> Using the Windows Service is really the best way to do it on Windows.
>> The use case is testing Tomcat 10 in various ways, including running it in
>> debug mode and attaching via IntelliJ for inspection.
>>
>> ---rony
>>
>> -
>> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
>> For additional commands, e-mail: users-h...@tomcat.apache.org
> The bat-file uses the line:
> call "%EXECUTABLE%" start %CMD_LINE_ARGS%
>
> At this place you might be able to redirect the output:
> call "%EXECUTABLE%" start %CMD_LINE_ARGS%  > out.log
>
> You could also try to pass the redirect param to the argument of startup.bat, 
> don’t know if this works, e.g.
> startup.bat " > out.log"

startup.bat uses start to run catalina.bat in a new cmd window with:

call "%EXECUTABLE%" start %CMD_LINE_ARGS%

catalina.bat then starts Tomcat as:

%_EXECJAVA% %CATALINA_LOGGING_CONFIG% %LOGGING_MANAGER% %JAVA_OPTS% 
%CATALINA_OPTS% %DEBUG_OPTS%
-D%ENDORSED_PROP%="%JAVA_ENDORSED_DIRS%" -classpath "%CLASSPATH%"
-Dcatalina.base="%CATALINA_BASE%" -Dcatalina.home="%CATALINA_HOME%"
-Djava.io.tmpdir="%CATALINA_TMPDIR%" %MAINCLASS% %CMD_LINE_ARGS% 2>&1 1>
D:\orx.debug\work_rii_tomcat\test.log

This does not work.

---rony