Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to view the console output of tomcat

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

During the debugging of a web project, it is often necessary to check the output debugging information. For example, when Hibernate is set to display SQL statements, each run SQL statement will be output to the terminal, and sometimes some output statements need to be inserted into the code to facilitate the operation, but when inserting System.out.println (....) When such a console outputs statements, it cannot be seen directly at the terminal.

In tomcat, the terminal output information is output to the

$CATALINA_HOME/logs/catalina.out

Where $CATALINA_HOME is the directory where tomcat is installed.

After tomcat starts, the file is updated every second, and log information is entered into it, so if you view the contents of the file directly, it is often difficult to achieve because the file is constantly refreshing. We want to see dynamic log content in two ways:

1. Mode one

Go to the bin directory of the tomcat installation path and run the sh catalina.sh run command, which will dynamically display the contents of catalina.out on the terminal.

two。 Mode two

Enter the logs directory under the above installation directory and execute the following command

Tail-f catalina.out

The method of outputting logs to files in Tomcat console

Modify in startup.bat

Call "EXECUTABLE%" start CMD_LINE_ARGS%

For

Call "% EXECUTABLE%" run% CMD_LINE_ARGS% (>..\ logs\ detailLog.%DATE:~0,10%.log)

In this way, the console will not output the log file. Let catalina.bat decide where the log output is.

Look for four places in catalina.bat that end with% ACTION%, adding > >..\ logs\ detailLog.%DATE:~0,10%.log after each% ACTION%.

DetailLog is my own name, you can change it at will, but be careful not to conflict with the default log file, otherwise startup will report an error. The% DATE:~0,10% is used to intercept the system time (here you should pay attention to the system-generated time format, if it is 2013-04-02, it will make an error, please make sure the system time format). On my server, echo% DATE%, shows "2013-04-02 Tuesday", intercepting 0-10 bits, that is, "2013-04-02", so the name of the log file generated today should be detailLog.2013-04-02.log.

Double-click startup.bat in this way, and you will find that the log file is no longer output after the console starts. If you check detailLog.2013-04-02.log again, you will find that the logs are all in it. The following work is how to simply display the log file.

Change the system date format in

Date and time settings in the lower right corner of the desktop-change calendar settings-modify the short date drop-down selection box under the date format under the date tab

Download UnxUtils https://sourceforge.net/projects/unxutils/

Extract and add UnxUtils\ usr\ local\ wbin to the system environment variable Path

Open cmd and enter tail-- help

The above is the whole content of this article, I hope it will be helpful to your study, and I also hope that you will support it.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report