Deploy tomcat under the windows server and record the tomcat console log to the log file

In the Linux system, Tomcat writes a lot of information to the catalina.out file by default after it is started. We can track the running situation of Tomcat and related applications through tail -f catalina.out. Under Windows, after we use startup.bat to start Tomcat, we will find that the content recorded in catalina log is very different from that recorded in Linux. Most of the information is only output to the screen and not recorded in catalina.out. The content of this article is to achieve under Windows, record the relevant console output to the background catalina.out file for future viewing.

Output console information to %CATALINA_BASE%\logs\catalina.out:

1. Open the startup.bat file under bin, and call "%EXECUTABLE%" start %CMD_LINE_ARGS% in the bottom line

     改为 call "%EXECUTABLE%" run %CMD_LINE_ARGS%

Note: After the above setting, after running tomcat, the log will not be displayed in the tomcat running window in real time.
 
2. Open the catalina.bat file under bin, and you will find that there are 4 %ACTION% in the file, and add them later
     >> %CATALINA_HOME%\logs\catalina.out 
 
Note: backslashes and linux are reversed in windows
Restart tomcat, you will find that the catalina.out file appears in the logs folder, and all the information of the original console is written into it.
But the output catalina.out file keeps growing, that is, the file will get bigger and bigger.
 
3. According to the above modification, all tomcat logs will be written to the logs/catalina.out file. If you want to generate log files by day,
You can add >> %CATALINA_HOME%/logs/catalina.%date:~0,4%-%date:~5,2%-%date:~8,2%.out after %ACTION%
The generated format is catalina.yyyy-mm-dd.out (yyyy represents a 4-digit year, mm represents a 2-digit month, and dd represents a two-digit date)

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325775582&siteId=291194637