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: Maybe a stupid (Windows related) question

2022-03-23 Thread Rony G. Flatscher (Apache)
On 23.03.2022 13:22, Mark Thomas wrote:
> On 23/03/2022 10:34, Rony G. Flatscher (Apache) wrote:
>> The use case is testing Tomcat 10 in various ways, including running it in 
>> debug mode and attaching
>> via IntelliJ for inspection.
>
> You can still do this when Tomcat is running as a service. Just set the 
> appropriate properties.

Yes, looks like I will have to do it that way.

(Currently I have a Tomcat 10 service installation that I shutdown and then run 
a different (newer),
separate Tomcat installation for testing purposes for which I need the 
redirection of stdout and
stderr.)

---rony



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



Re: Maybe a stupid (Windows related) question

2022-03-23 Thread Mark Thomas

On 23/03/2022 10:34, Rony G. Flatscher (Apache) wrote:

The use case is testing Tomcat 10 in various ways, including running it in 
debug mode and attaching
via IntelliJ for inspection.


You can still do this when Tomcat is running as a service. Just set the 
appropriate properties.


Mark

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



Re: Maybe a stupid (Windows related) question

2022-03-23 Thread Rony G. Flatscher (Apache)

On 23.03.2022 12:11, Rony G. Flatscher (Apache) wrote:
> On 23.03.2022 11:51, Konstantin Kolinko wrote:
>> вт, 22 мар. 2022 г. в 20:21, Rony G. Flatscher (Apache) :
>>> For debugging purposes I downloaded the zip-version of Tomcat 10.0.18 and 
>>> start it up using
>>> %CATALINA_HOME%\bin\startup.bat.
>>>
>>> 
>>>
>>> Probably I have been doing something wrong in the past hours and not seeing 
>>> the forest for the trees
>>> anymore I kindly request help: what is needed to successfully redirect 
>>> stderr and stdout to
>>> %CATALINA_HOME%\logs after unzipping Tomcat 10 and starting it on Windows 
>>> using
>>> %CATALINA_HOME%\bin\startup.bat?
>>>
>>> TIA for any help/pointer!
>> First, I second Chris's answer
>>
>> вт, 22 мар. 2022 г. в 22:19, Christopher Schultz 
>> :
>>> 
>>>
>>> ... Windows CAN redirect both stdout and stderr to
>>> two different places, and also to combine them just like you can on *nix:
>>>
>>> bin\catalina.bat run 2>&1 > stdout_stderr.log
>>>
>>> https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-xp/bb490982(v=technet.10)?redirectedfrom=MSDN
>>>
>> Note that
>> "startup.bat" is an equivalent of calling "catalina.bat start".
>> "shutdown.bat" is an equivalent of "catalina.bat stop".
>>
>> The above command (with " run") is a different one:
>> it starts Tomcat in the same console window, as opposed to " start"
>> that opens a new console window.
>>
>> Second,
>> To redirect java.util.logging output to a file, replace ConsoleHandler
>> in conf/logging.properties with a FileHandler that writes all those
>> log lines to a file.
>>
>> Actually, logging.properties already has such a FileHandler
>> configured. See the following line:
>>
>> .handlers = 1catalina.org.apache.juli.AsyncFileHandler,
>> java.util.logging.ConsoleHandler
>>
>> It configures handlers for "." (the root). So all the same information
>> is also being written to a "1catalina" FileHandler. Removing the
>> "ConsoleHandler" from that line will stop duplicating all those log
>> messages to the console.
> The %CATALINA_HOME%\conf\logging.properties got changed according to
> 
> as:
>
> handlers = 1catalina.org.apache.juli.AsyncFileHandler,
> 2localhost.org.apache.juli.AsyncFileHandler, 
> 3manager.org.apache.juli.Async
> FileHandler, 4host-manager.org.apache.juli.AsyncFileHandler, 
> java.util.logging.ConsoleHandler
>
> # .handlers = 1catalina.org.apache.juli.AsyncFileHandler, 
> java.util.logging.ConsoleHandler
>
> .handlers = 1catalina.org.apache.juli.AsyncFileHandler
>
> ... cut ...
>
> Still stdout and stderr goes to the console. The redirection "2>&1 >test.log" 
> creates the empty file
> but no output is there.
>
>> Third,
>> If you app is actually calling System.err.println(), see about
>> "swallowOutput" setting here
>> https://tomcat.apache.org/tomcat-10.0-doc/logging.html#Console
>> https://tomcat.apache.org/tomcat-10.0-doc/config/context.html
> Will try that next thank you!

Tried two ways:

  * %CATALINA_HOME%\conf\context.xml adding attribute, so " only

Did not make a difference.

Having permutated so many different things I will delete everything and start 
over with a pristine
unzipped Tomcat 10 to see if that makes a difference.

---rony




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




Re: Maybe a stupid (Windows related) question

2022-03-23 Thread Rony G. Flatscher (Apache)

On 23.03.2022 11:51, Konstantin Kolinko wrote:
> вт, 22 мар. 2022 г. в 20:21, Rony G. Flatscher (Apache) :
>> For debugging purposes I downloaded the zip-version of Tomcat 10.0.18 and 
>> start it up using
>> %CATALINA_HOME%\bin\startup.bat.
>>
>> 
>>
>> Probably I have been doing something wrong in the past hours and not seeing 
>> the forest for the trees
>> anymore I kindly request help: what is needed to successfully redirect 
>> stderr and stdout to
>> %CATALINA_HOME%\logs after unzipping Tomcat 10 and starting it on Windows 
>> using
>> %CATALINA_HOME%\bin\startup.bat?
>>
>> TIA for any help/pointer!
> First, I second Chris's answer
>
> вт, 22 мар. 2022 г. в 22:19, Christopher Schultz 
> :
>> 
>>
>> ... Windows CAN redirect both stdout and stderr to
>> two different places, and also to combine them just like you can on *nix:
>>
>> bin\catalina.bat run 2>&1 > stdout_stderr.log
>>
>> https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-xp/bb490982(v=technet.10)?redirectedfrom=MSDN
>>
> Note that
> "startup.bat" is an equivalent of calling "catalina.bat start".
> "shutdown.bat" is an equivalent of "catalina.bat stop".
>
> The above command (with " run") is a different one:
> it starts Tomcat in the same console window, as opposed to " start"
> that opens a new console window.
>
> Second,
> To redirect java.util.logging output to a file, replace ConsoleHandler
> in conf/logging.properties with a FileHandler that writes all those
> log lines to a file.
>
> Actually, logging.properties already has such a FileHandler
> configured. See the following line:
>
> .handlers = 1catalina.org.apache.juli.AsyncFileHandler,
> java.util.logging.ConsoleHandler
>
> It configures handlers for "." (the root). So all the same information
> is also being written to a "1catalina" FileHandler. Removing the
> "ConsoleHandler" from that line will stop duplicating all those log
> messages to the console.

The %CATALINA_HOME%\conf\logging.properties got changed according to

as:

handlers = 1catalina.org.apache.juli.AsyncFileHandler,
2localhost.org.apache.juli.AsyncFileHandler, 3manager.org.apache.juli.Async
FileHandler, 4host-manager.org.apache.juli.AsyncFileHandler, 
java.util.logging.ConsoleHandler

# .handlers = 1catalina.org.apache.juli.AsyncFileHandler, 
java.util.logging.ConsoleHandler

.handlers = 1catalina.org.apache.juli.AsyncFileHandler

... cut ...

Still stdout and stderr goes to the console. The redirection "2>&1 >test.log" 
creates the empty file
but no output is there.

> Third,
> If you app is actually calling System.err.println(), see about
> "swallowOutput" setting here
> https://tomcat.apache.org/tomcat-10.0-doc/logging.html#Console
> https://tomcat.apache.org/tomcat-10.0-doc/config/context.html

Will try that next thank you!

---rony



Re: Maybe a stupid (Windows related) question

2022-03-23 Thread Konstantin Kolinko
вт, 22 мар. 2022 г. в 20:21, Rony G. Flatscher (Apache) :
>
> For debugging purposes I downloaded the zip-version of Tomcat 10.0.18 and 
> start it up using
> %CATALINA_HOME%\bin\startup.bat.
>
> 
>
> Probably I have been doing something wrong in the past hours and not seeing 
> the forest for the trees
> anymore I kindly request help: what is needed to successfully redirect stderr 
> and stdout to
> %CATALINA_HOME%\logs after unzipping Tomcat 10 and starting it on Windows 
> using
> %CATALINA_HOME%\bin\startup.bat?
>
> TIA for any help/pointer!

First, I second Chris's answer

вт, 22 мар. 2022 г. в 22:19, Christopher Schultz :
> 
>
> ... Windows CAN redirect both stdout and stderr to
> two different places, and also to combine them just like you can on *nix:
>
> bin\catalina.bat run 2>&1 > stdout_stderr.log
>
> https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-xp/bb490982(v=technet.10)?redirectedfrom=MSDN
>

Note that
"startup.bat" is an equivalent of calling "catalina.bat start".
"shutdown.bat" is an equivalent of "catalina.bat stop".

The above command (with " run") is a different one:
it starts Tomcat in the same console window, as opposed to " start"
that opens a new console window.

Second,
To redirect java.util.logging output to a file, replace ConsoleHandler
in conf/logging.properties with a FileHandler that writes all those
log lines to a file.

Actually, logging.properties already has such a FileHandler
configured. See the following line:

.handlers = 1catalina.org.apache.juli.AsyncFileHandler,
java.util.logging.ConsoleHandler

It configures handlers for "." (the root). So all the same information
is also being written to a "1catalina" FileHandler. Removing the
"ConsoleHandler" from that line will stop duplicating all those log
messages to the console.

Third,
If you app is actually calling System.err.println(), see about
"swallowOutput" setting here
https://tomcat.apache.org/tomcat-10.0-doc/logging.html#Console
https://tomcat.apache.org/tomcat-10.0-doc/config/context.html

Best regards,
Konstantin Kolinko

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



AW: Maybe a stupid (Windows related) question

2022-03-23 Thread Thomas Hoffmann (Speed4Trade GmbH)


> -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"



Re: Maybe a stupid (Windows related) question

2022-03-23 Thread Rony G. Flatscher (Apache)
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



Re: Maybe a stupid (Windows related) question

2022-03-22 Thread Christopher Schultz

All,

On 3/22/22 15:12, Christopher Schultz wrote:

Rony,

On 3/22/22 13:21, Rony G. Flatscher (Apache) wrote:
For debugging purposes I downloaded the zip-version of Tomcat 10.0.18 
and start it up using

%CATALINA_HOME%\bin\startup.bat.

This will create by default a separate process (terminal, commandline 
window) in which Tomcat runs
and dispatches all output including stdout and stderr output into that 
window.


By contrast the Windows service installation would redirect stdout and 
stderr by default to
%CATALINA_HOME%\logs\ using "tomcat10-stderr.yyy-mm-dd.log" and 
"tomcat10-stdout.-mm-dd.log" as
their name. The same would be desired for the "startup.bat" version of 
Tomcat 10.


Windows does not appear to have any of the following features woich 
would be required for that behavior:


1. nohup
2. backgrounding of CLI processes
3. shell-based redirection of stderr

I think you can achieve all of the above if you use catalina.sh from 
within bash-on-Windows, but I'm no expert.


You may also be able to do this kind of thing with a PowerShell script. 
Again, I'm no expert. But it couldn't be a .bat file, it'd have to be a 
.ps1 file instead.


Probably I have been doing something wrong in the past hours and not 
seeing the forest for the trees
anymore I kindly request help: what is needed to successfully redirect 
stderr and stdout to
%CATALINA_HOME%\logs after unzipping Tomcat 10 and starting it on 
Windows using

%CATALINA_HOME%\bin\startup.bat?


I don't believe this is possible. You may be able to somewhat simulate 
what you want by using:


C:> bin\catalina.bat run > stdout_and_stderr.log

But you won't get the C:> prompt back, and your cmd.exe window will have 
to stay open until you stop the Tomcat process.
Aaand, I'm already wrong. Windows CAN redirect both stdout and stderr to 
two different places, and also to combine them just like you can on *nix:


bin\catalina.bat run 2>&1 > stdout_stderr.log

https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-xp/bb490982(v=technet.10)?redirectedfrom=MSDN

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.


Using the Windows Service is really the best way to do it on Windows.

-chris


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



Re: Maybe a stupid (Windows related) question

2022-03-22 Thread Christopher Schultz

Rony,

On 3/22/22 13:21, Rony G. Flatscher (Apache) wrote:

For debugging purposes I downloaded the zip-version of Tomcat 10.0.18 and start 
it up using
%CATALINA_HOME%\bin\startup.bat.

This will create by default a separate process (terminal, commandline window) 
in which Tomcat runs
and dispatches all output including stdout and stderr output into that window.

By contrast the Windows service installation would redirect stdout and stderr 
by default to
%CATALINA_HOME%\logs\ using "tomcat10-stderr.yyy-mm-dd.log" and 
"tomcat10-stdout.-mm-dd.log" as
their name. The same would be desired for the "startup.bat" version of Tomcat 
10.


Windows does not appear to have any of the following features woich 
would be required for that behavior:


1. nohup
2. backgrounding of CLI processes
3. shell-based redirection of stderr

I think you can achieve all of the above if you use catalina.sh from 
within bash-on-Windows, but I'm no expert.


You may also be able to do this kind of thing with a PowerShell script. 
Again, I'm no expert. But it couldn't be a .bat file, it'd have to be a 
.ps1 file instead.



Probably I have been doing something wrong in the past hours and not seeing the 
forest for the trees
anymore I kindly request help: what is needed to successfully redirect stderr 
and stdout to
%CATALINA_HOME%\logs after unzipping Tomcat 10 and starting it on Windows using
%CATALINA_HOME%\bin\startup.bat?


I don't believe this is possible. You may be able to somewhat simulate 
what you want by using:


C:> bin\catalina.bat run > stdout_and_stderr.log

But you won't get the C:> prompt back, and your cmd.exe window will have 
to stay open until you stop the Tomcat process.


Hope that helps,
-chris

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



RE: Maybe a stupid (Windows related) question

2022-03-22 Thread jonmcalexander
> -Original Message-
> From: Rony G. Flatscher (Apache) 
> Sent: Tuesday, March 22, 2022 12:21 PM
> To: users@tomcat.apache.org
> Subject: Maybe a stupid (Windows related) question
> 
> For debugging purposes I downloaded the zip-version of Tomcat 10.0.18 and
> start it up using %CATALINA_HOME%\bin\startup.bat.
> 
> This will create by default a separate process (terminal, commandline
> window) in which Tomcat runs and dispatches all output including stdout and
> stderr output into that window.
> 
> By contrast the Windows service installation would redirect stdout and stderr
> by default to %CATALINA_HOME%\logs\ using "tomcat10-stderr.yyy-mm-
> dd.log" and "tomcat10-stdout.-mm-dd.log" as their name. The same
> would be desired for the "startup.bat" version of Tomcat 10.
> 
> Searched
> <https://urldefense.com/v3/__https://tomcat.apache.org/tomcat-10.0-
> doc/logging.html__;!!F9svGWnIaVPGSwU!73l7pAR1e6xCG3INKjeg0PnyhD7k
> yWl2kyHrFKAdlps4BB1jpO4ZbG-apDxsEvad_K823Jw$ > and
> <https://urldefense.com/v3/__https://tomcat.apache.org/tomcat-10.0-
> doc/setup.html__;!!F9svGWnIaVPGSwU!73l7pAR1e6xCG3INKjeg0PnyhD7ky
> Wl2kyHrFKAdlps4BB1jpO4ZbG-apDxsEvadogS4Vco$ > to no avail. Searching
> the Internet the best I could find was
> <https://urldefense.com/v3/__https://serverfault.com/questions/252934/h
> ow-to-redirect-tomcat-console-log-to-files-tomcat-started-via-windows-
> bat__;!!F9svGWnIaVPGSwU!73l7pAR1e6xCG3INKjeg0PnyhD7kyWl2kyHrFKA
> dlps4BB1jpO4ZbG-apDxsEvadZtWA7FE$ > which indeed redirects the Tomcat
> startup information to %CATALINA_HOME%\logs\catalina.-mm-dd.log,
> but not stdout and stderr which do not get redirected.
> Using redirections directly in "startup.bat" or "catalina.bat" as suggested
> further down in the serverfault.com did not yield the desired redirection.
> 
> Probably I have been doing something wrong in the past hours and not
> seeing the forest for the trees anymore I kindly request help: what is needed
> to successfully redirect stderr and stdout to %CATALINA_HOME%\logs after
> unzipping Tomcat 10 and starting it on Windows using
> %CATALINA_HOME%\bin\startup.bat?
> 
> TIA for any help/pointer!
> 
> ---rony
> 
> 
> 
> -
> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: users-h...@tomcat.apache.org

Would it not be best to use CATALINA_BASE instead of CATALINA_HOME? The idea 
being that HOME should be the binaries, and BASE is mobile Just my .02 
worth.

Thanks,



Dream * Excel * Explore * Inspire
Jon McAlexander
Infrastructure Engineer
Asst Vice President
He/His

Middleware Product Engineering
Enterprise CIO | EAS | Middleware | Infrastructure Solutions

8080 Cobblestone Rd | Urbandale, IA 50322
MAC: F4469-010
Tel 515-988-2508 | Cell 515-988-2508

jonmcalexan...@wellsfargo.com
This message may contain confidential and/or privileged information. If you are 
not the addressee or authorized to receive this for the addressee, you must not 
use, copy, disclose, or take any action based on this message or any 
information herein. If you have received this message in error, please advise 
the sender immediately by reply e-mail and delete this message. Thank you for 
your cooperation.


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



Re: Maybe a stupid (Windows related) question

2022-03-22 Thread Noelette Stout
maybe redirect stderr to stdout then redirect to the log:  startup.bat 2>&1
1>yourFile.log
I believe that kind of redirection works in Windows as well as Linux (but
it's been a while since I had to do that sort of thing in Windows, so I may
be mistaken)

On Tue, Mar 22, 2022 at 11:26 AM Rob Sargent  wrote:

>
>
> On 3/22/22 11:21, Rony G. Flatscher (Apache) wrote:
> > For debugging purposes I downloaded the zip-version of Tomcat 10.0.18
> and start it up using
> > %CATALINA_HOME%\bin\startup.bat.
> >
> > This will create by default a separate process (terminal, commandline
> window) in which Tomcat runs
> > and dispatches all output including stdout and stderr output into that
> window.
> >
> > By contrast the Windows service installation would redirect stdout and
> stderr by default to
> > %CATALINA_HOME%\logs\ using "tomcat10-stderr.yyy-mm-dd.log" and
> "tomcat10-stdout.-mm-dd.log" as
> > their name. The same would be desired for the "startup.bat" version of
> Tomcat 10.
> >
> > Searched  and
> >  to no avail.
> Searching the Internet the best
> > I could find
> > was
> > <
> https://serverfault.com/questions/252934/how-to-redirect-tomcat-console-log-to-files-tomcat-started-via-windows-bat
> >
> > which indeed redirects the Tomcat startup information to
> > %CATALINA_HOME%\logs\catalina.-mm-dd.log, but not stdout and stderr
> which do not get redirected.
> > Using redirections directly in "startup.bat" or "catalina.bat" as
> suggested further down in the
> > serverfault.com did not yield the desired redirection.
> >
> > Probably I have been doing something wrong in the past hours and not
> seeing the forest for the trees
> > anymore I kindly request help: what is needed to successfully redirect
> stderr and stdout to
> > %CATALINA_HOME%\logs after unzipping Tomcat 10 and starting it on
> Windows using
> > %CATALINA_HOME%\bin\startup.bat?
> >
> > TIA for any help/pointer!
> >
> > ---rony
> >
> >
> >
> > -
> > To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
> > For additional commands, e-mail: users-h...@tomcat.apache.org
> >
> Maybe startup.bat > your.log
>
> -
> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: users-h...@tomcat.apache.org
>
>

-- 
Noelette Stout
ITS Enterprise Applications - Senior Application Administrator
Idaho State University
E-mail: stounoel "at" isu "dot" edu
Desk: 208-282-2554


Re: Maybe a stupid (Windows related) question

2022-03-22 Thread Rob Sargent




On 3/22/22 11:21, Rony G. Flatscher (Apache) wrote:

For debugging purposes I downloaded the zip-version of Tomcat 10.0.18 and start 
it up using
%CATALINA_HOME%\bin\startup.bat.

This will create by default a separate process (terminal, commandline window) 
in which Tomcat runs
and dispatches all output including stdout and stderr output into that window.

By contrast the Windows service installation would redirect stdout and stderr 
by default to
%CATALINA_HOME%\logs\ using "tomcat10-stderr.yyy-mm-dd.log" and 
"tomcat10-stdout.-mm-dd.log" as
their name. The same would be desired for the "startup.bat" version of Tomcat 
10.

Searched  and
 to no avail. Searching 
the Internet the best
I could find
was

which indeed redirects the Tomcat startup information to
%CATALINA_HOME%\logs\catalina.-mm-dd.log, but not stdout and stderr which 
do not get redirected.
Using redirections directly in "startup.bat" or "catalina.bat" as suggested 
further down in the
serverfault.com did not yield the desired redirection.

Probably I have been doing something wrong in the past hours and not seeing the 
forest for the trees
anymore I kindly request help: what is needed to successfully redirect stderr 
and stdout to
%CATALINA_HOME%\logs after unzipping Tomcat 10 and starting it on Windows using
%CATALINA_HOME%\bin\startup.bat?

TIA for any help/pointer!

---rony



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


Maybe startup.bat > your.log

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



Maybe a stupid (Windows related) question

2022-03-22 Thread Rony G. Flatscher (Apache)
For debugging purposes I downloaded the zip-version of Tomcat 10.0.18 and start 
it up using
%CATALINA_HOME%\bin\startup.bat.

This will create by default a separate process (terminal, commandline window) 
in which Tomcat runs
and dispatches all output including stdout and stderr output into that window.

By contrast the Windows service installation would redirect stdout and stderr 
by default to
%CATALINA_HOME%\logs\ using "tomcat10-stderr.yyy-mm-dd.log" and 
"tomcat10-stdout.-mm-dd.log" as
their name. The same would be desired for the "startup.bat" version of Tomcat 
10.

Searched  and
 to no avail. Searching 
the Internet the best
I could find
was

which indeed redirects the Tomcat startup information to
%CATALINA_HOME%\logs\catalina.-mm-dd.log, but not stdout and stderr which 
do not get redirected.
Using redirections directly in "startup.bat" or "catalina.bat" as suggested 
further down in the
serverfault.com did not yield the desired redirection.

Probably I have been doing something wrong in the past hours and not seeing the 
forest for the trees
anymore I kindly request help: what is needed to successfully redirect stderr 
and stdout to
%CATALINA_HOME%\logs after unzipping Tomcat 10 and starting it on Windows using
%CATALINA_HOME%\bin\startup.bat?

TIA for any help/pointer!

---rony



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