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.yyyy-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

Reply via email to