How To Show Live Tomcat Log In MacOS

After you install tomcat in MacOS, you can start it and stop it with command. Article How To Install Tomcat In MacOS has told you how to do that. But after you start it, you can not find the log data in the terminal like windows. This may make you crazy, because you can not get debug or error information when the tomcat server can not be accessed. Do not worry, this article will tell you how to live show the tomcat logs in the terminal.

1. Add Tomcat Executable In Path Environment Variable.

The How To Install Tomcat In MacOS is not perfect because you must go to Tomcat_Home/bin folder to run to start/stop the tomcat server for each time. You have to remember Tomcat_Home directory, this is not user friendly.

To resolve above issue, you can add Tomcat_Home/bin folder into the OS PATH environment variable value, then you can type at any directory level to start/stop it. Below are steps.

  1. CD to user home directory.
    192:~ $ cd ~
  2. Edit user bash profile file.
    192:~ $ vim .bash_profile
  3. Add Tomcat_Home/bin folder in the PATH variable value. Press i in vim to insert text, then copy and paste Tomcat_Home/bin folder to PATH value.
  4. Press shift + : then wq! to save the changes.
  5. Run source command in terminal to make the change take effect.
    192:~$ source .bash_profile
  6. Now you can start/stop tomcat server at any directory level in terminal.

2. Live Show Tomcat Server Log In Terminal.

After section one, you can start tomcat at anywhere, but after start you are confused that it do not output the tomcat logs in the terminal. This make you seriously when you want to see the log for fix bugs or resolve error in live time.

Do not crazy, let us follow bellow steps to show the tomcat log in live time.

  1. If you do not know where the tomcat installed, you can run below command to get it. The tomcat will execute to start it.
    192:~ $ ps -ef|grep catalina

    ps -ef grep catalina to get tomcat installed directory

  2. Tomcat logs are saved in Tomcat_Home/logs/catalina.out file. So to live show tomcat logs, you can use tail -f command in terminal, tail -f command will display the latest logs in the catalina.out file in terminal.
    192:~ $ tail -f /Users/zhaosong/Documents/WorkSpace/tool/apache-tomcat-9.0.8/logs/catalina.out 
0 0 vote
Article Rating
Notify of

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Inline Feedbacks
View all comments
Would love your thoughts, please comment.x