You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Peter Rader <p....@gmx.net.INVALID> on 2024/05/15 17:43:36 UTC
Logrotation throu CATALINA_OUT_CMD in Tomcat9
Hi,
my catalina.out is getting bigger and bigger.
In order to have smaller catalina.out I noticed this environment-variable: CATALINA_OUT_CMD
Inside the catalina.sh is documented:
# CATALINA_OUT_CMD (Optional) Command which will be executed and receive
# as its stdin the stdout and stderr from the Tomcat java
# process. If CATALINA_OUT_CMD is set, the value of
# CATALINA_OUT will be used as a named pipe.
# No default.
# Example (all one line)
# CATALINA_OUT_CMD="/usr/bin/rotatelogs -f $CATALINA_BASE/logs/catalina.out.%Y-%m-%d.log 86400"
I try to use that example and export this variable before start of tomcat:
export CATALINA_OUT_CMD="/usr/bin/rotatelogs -f /home/tomcat/apache-tomcat-9.0.75/logs/catalina.out.%Y-%m-%d.log 86400"
Unfortunately the tomcat does not work anymore, instead this message appear:
/home/tomcat/apache-tomcat-9.0.75/logs/catalina.out exists and is not a named pipe. Start aborted.
Any Ideas?
Kind regards
Peter Rader
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Aw: Re: Logrotation throu CATALINA_OUT_CMD in Tomcat9
Posted by Peter Rader <p....@gmx.net.INVALID>.
> You need to do what the instructions state: create a FIFO and specify its name in the CATALINA_OUT variable. For example, do
Ah, yes,
mkfifo catalina.out
fixed it for me. I had no idea what a fifo is, now I knew.
Kind regards
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: Logrotation throu CATALINA_OUT_CMD in Tomcat9
Posted by Chuck Caldarale <n8...@gmail.com>.
> On May 15, 2024, at 12:43, Peter Rader <p....@gmx.net.INVALID> wrote:
>
> my catalina.out is getting bigger and bigger.
(I should Insert a philosophical discussion on not using stdout for application logging here, but I’ll leave that for some other time.)
> In order to have smaller catalina.out I noticed this environment-variable: CATALINA_OUT_CMD
>
> Inside the catalina.sh is documented:
>
> # CATALINA_OUT_CMD (Optional) Command which will be executed and receive
> # as its stdin the stdout and stderr from the Tomcat java
> # process. If CATALINA_OUT_CMD is set, the value of
> # CATALINA_OUT will be used as a named pipe.
> # No default.
> # Example (all one line)
> # CATALINA_OUT_CMD="/usr/bin/rotatelogs -f $CATALINA_BASE/logs/catalina.out.%Y-%m-%d.log 86400"
>
> I try to use that example and export this variable before start of tomcat:
>
> export CATALINA_OUT_CMD="/usr/bin/rotatelogs -f /home/tomcat/apache-tomcat-9.0.75/logs/catalina.out.%Y-%m-%d.log 86400"
>
> Unfortunately the tomcat does not work anymore, instead this message appear:
>
> /home/tomcat/apache-tomcat-9.0.75/logs/catalina.out exists and is not a named pipe. Start aborted.
You need to do what the instructions state: create a FIFO and specify its name in the CATALINA_OUT variable. For example, do
mkfifo logs/catalina_out.pipe
one time, before starting Tomcat, then add the following to bin/setenv.sh:
export CATALINA_OUT="$CATALINA_HOME/logs/catalina_out.pipe"
export CATALINA_OUT_CMD=“rotatelogs -f $CATALINA_HOME/logs/catalina.out.%Y-%m-%d.log 86400"
This causes Tomcat to use the named pipe rather than logs/catalina.out for stdout and stderr messages, and then invoke rotatelogs to process the entries. As an alternative to setting CATALINA_OUT, you could just delete the existing logs/catalina.out file and recreate it as a FIFO, but I wouldn’t recommend it due to potential confusion.
- Chuck