3

I want to read my console output logs, and I know that they are stored into "log" folder under the file catalina.out, but it doesn't exists! I have tried in different ways with no results. I don't know how to figure it out, I just want to see my java outputs logs

Giacomo Brunetta
  • 1,409
  • 3
  • 18
  • 38
  • Look at the script that is used to start your Tomcat. – Stephen C May 31 '18 at 14:29
  • 1
    What is your OS? Sometimes tomcat on Linux writes directly to system log (whatever it is). In my case, I check the logs with `journalctl -f -u tomcat`. – LMC May 31 '18 at 23:42

4 Answers4

5

If the catalina.out is deleted after tomcat is stopped, it will create a new catalina.out once tomcat starts again and it is totally safe.

But if you remove the catalina.out while tomcat is running, it will keep on logging to catalina.out which is removed already (reference of the file is hold by the tomcat) hence the space will not be released. So you will need to restart the tomcat sever to release the space. It is not recommended.

Start/ Run Tomcat server and it should create catalina.out file without any error.

Following are the multiple ways of running tomcat. Just indicated in detail so this would help someone in need.

./catalina.sh run

Passing "run" argument for catalina.sh --> starts the Tomcat in the foreground and displays the running logs in the same console. when the console terminal is closed it will terminate the tomcat.

./catalina.sh start

Passing "start" argument for catalina.sh --> starts the Tomcat in the background. Since in background no issues closing down the terminal. The logs need to be viewed as below: tail -f $CATALINA_HOME/logs/catalina.out

./startup.sh 

The last way is firing the startup.sh to start your Tomcat server. If you Vi the script you can see it calls catalina.sh script passing start as the argument. This will be running in background as well.

Now check your tomcat log directory and you should find the catalina.out

Du-Lacoste
  • 11,530
  • 2
  • 71
  • 51
4

From catalina.sh , it says :

#   CATALINA_OUT    (Optional) Full path to a file where stdout and stderr
#                   will be redirected.
#                   Default is $CATALINA_BASE/logs/catalina.out

So , look at your script that is used to start Tomcat to find out what the value of the environment variable CATALINA_OUT.

Ken Chan
  • 84,777
  • 26
  • 143
  • 172
  • Thus, I have to find that value from Tomcat startup script? Why? – Giacomo Brunetta Jun 01 '18 at 08:12
  • How can you start tomcat now ? I mean looking at the your script that is used to start tomcat. – Ken Chan Jun 01 '18 at 13:22
  • @KenChan, in `apache-tomcat-9` there is no text which you pasted. I don't see `CATALINA_OUT` in `catalina.sh` file. There are only `CATALINA_HOME`, `CATALINA_BASE` and `CATALINA_OPTS` – Michu93 Jan 25 '22 at 11:58
3

go to the bin folder of tomcat and run below script ./catalina.sh start

now catalina.out exist in logs folder

Michu93
  • 5,058
  • 7
  • 47
  • 80
NITIN RATHOUR
  • 161
  • 2
  • 3
1

When we upgraded our Beanstalks to Tomcat 8.5 with Corretto 11 running on 64bit Amazon Linux 2, catalina.out no longer existed and not all logs were present in catalina.date.log. We re-established the catalina.out with the following file dropped into /etc/rsyslog.d/catalina.conf

$umask 0000
$FileCreateMode 0644
template(name="Tomcat" type="string" string="%msg%\n") {
  property(name="msg")
}
if $programname == 'tomcat' then {
    action(type="omfile" file="/var/log/tomcat/catalina.out" template="Tomcat")
}
if  $programname == 'server' then {
    action(type="omfile" file="/var/log/tomcat/catalina.out" template="Tomcat")
}

you will want to restart rsyslog afterwards.

service rsyslog restart
mohrt
  • 11
  • 3
  • Thanks for that, I just put this script inside .ebextensions folder to get it automatically. However noticed that many of this messages was already saved in '/var/log/messages' file. – edudoda Oct 26 '22 at 01:53