Disclaimer: The above content is reproduced, the individual to this piece of knowledge after the put together, not original, later this block has problems will continue to add.
- The Tomcat logs fall into the following 5 categories:
Catalina, equivalent command line output log
localhost, command line output log equivalent to localhost
Manager, managed logs
Host-manager should be a virtual hosting aspect
The level of each type of log is divided into the following 7 types:
SEVERE (highest value) > WARNING > INFO > CONFIG > FINE > Finer > FINEST (lowest value)
Tomcat generates files in the logs directory every day: Catalina.out, Catalina. Y-m-d.log, localhost. Y-m-d.log, manager. Y-m-d.log, Host-manager. Y-m-d.log
You can change the way the log is generated by modifying the Conf\logging.properties file.
There are three commands in the Linux system that can be used to view all the files, namely the cat, more, and less commands. Their access to the use of the file is also relatively simple command file name , but the three are different.
1.cat command can display the entire file at once, if the file is relatively large, the use is not very convenient;
The 2.more command pauses the screen when it is full, and you can press the empty SPACEBAR to continue with the next screen, or press the Q key to stop the display.
The 3.less command can also be paged to display files, and the more command is the difference is that it supports scrolling up and down the screen, when the end of the browsing, as long as the less command prompt ":" Press the Q key.
In addition, in most cases the more and less commands will match the pipe character to page out what needs to be displayed on the screen
Live view of Tomcat runtime logs under Linux
1, first switch to: CD usr/local/tomcat5/logs
2,tail-f catalina.out
3, so that the runtime can view the running log in real time
CTRL + C is the exit Tail command.
By the way, the tail command in Linux
The tail command writes the file to standard output starting at the specified point. Using the-f option of the tail command makes it easy to see the log files that are being changed, TAIL-F filename will display the most up-to-date contents of the filename on the screen, and not only refresh, so you can view the latest file content.
1. command format;
tail[necessary parameters [selection parameters] [file]
2. Command function:
Used to display the content at the end of the specified file, and is processed as input when the file is not specified. Common view log files.
3. Command parameters:
-F Loop Read
-Q does not display processing information
-V displays detailed processing information
Number of-c< > bytes displayed
-n< lines > Display rows
--pid=pid is shared with-F, which means that the process ends after the id,pid dies.
-Q,--quiet,--silent never output the header of the file name
-S,--sleep-interval=s is combined with-F, which means sleep s seconds at each repetition interval
4. Usage examples:
Example 1: Displaying the end of a file
Command:
Tail-n 5 Log2014.log
Output:
?
123456 |
[[email protected] test]# tail -n 5 log2014.log 2014-09 2014-10 2014-11 2014-12 ==============================[[email protected] test]# |
Description
Displays the last 5 lines of the file
Example 2: Looping through the contents of a file
Command:
Tail-f Test.log
Output:
?
123456789101112131415 |
[[email protected] ~]# ping 192.168.120.204 > test.log &
[1] 11891[[email protected] ~]# tail -f test.log
PING 192.168.120.204 (192.168.120.204) 56(84) bytes of data.
64 bytes from 192.168.120.204: icmp_seq=1 ttl=64 time=0.038 ms
64 bytes from 192.168.120.204: icmp_seq=2 ttl=64 time=0.036 ms
64 bytes from 192.168.120.204: icmp_seq=3 ttl=64 time=0.033 ms
64 bytes from 192.168.120.204: icmp_seq=4 ttl=64 time=0.027 ms
64 bytes from 192.168.120.204: icmp_seq=5 ttl=64 time=0.032 ms
64 bytes from 192.168.120.204: icmp_seq=6 ttl=64 time=0.026 ms
64 bytes from 192.168.120.204: icmp_seq=7 ttl=64 time=0.030 ms
64 bytes from 192.168.120.204: icmp_seq=8 ttl=64 time=0.029 ms
64 bytes from 192.168.120.204: icmp_seq=9 ttl=64 time=0.044 ms
64 bytes from 192.168.120.204: icmp_seq=10 ttl=64 time=0.033 ms
64 bytes from 192.168.120.204: icmp_seq=11 ttl=64 time=0.027 ms
[[email protected] ~]#
|
Description
Ping 192.168.120.204 > Test.log &//Ping remote host in background. and output files to Test.log; This practice also allows for more than one file to monitor. Use CTRL + C to terminate.
Example 3: Displaying a file starting from line 5th
Command:
Tail-n +5 Log2014.log
Output:
?
123456789101112131415161718192021222324 |
[[email protected] test]# cat log2014.log
2014-01
2014-02
2014-03
2014-04
2014-05
2014-06
2014-07
2014-08
2014-09
2014-10
2014-11
2014-12
==============================
[[email protected] test]# tail -n +5 log2014.log
2014-05
2014-06
2014-07
2014-08
2014-09
2014-10
2014-11
2014-12
==============================
|
Utility Commands:
View the Tomcat run log |
Tail-f Catalina.out |
View logs with keyword search |
Cat Jeewx-2015-09-20.log | grep Verification Code |
Viewing a fixed time log |
Cat Jeewx-2015-09-20.log | grep ' 2015-09-20 18:50:15 ' |
View recent logs |
Tail-n 50-f Catalina.out |
Cat |
Show entire file |
Tail |
The tail command is used to display the end lines of a text file |
Head |
Starting from the head of the text file, the Head command is used to view the beginning of a text file |
More |
View the log as a percentage |
Less |
Similar to more functions, but less support to scroll through the files before and after |
Linux View Tomcat logs