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

Summary of necessary log analysis commands for Java development

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article focuses on "Java development essential log analysis command summary", interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Next let the editor to take you to learn the "Java development essential log analysis commands summary" bar!

Cat views the contents of the file

The cat command is a convenient tool to display the contents of a text file. If a log file is relatively small, you can directly use the cat command to print out its contents and view them. However, for larger log files, please do not do so. Opening a large file may take up too much system resources, thus affecting the external services of the system.

Command format:

Cat [options] [files]...

More pagination display file

The disadvantage of cat is that, once executed, it can no longer interact and control, and the more command can display the contents of the file in pages, press the enter key to display the next line of the file, press the space bar to display the next page, press the f key to display the next screen content, and press the b key to display the previous screen content.

Command format:

More [- dlfpcsu] [- num] [+ / pattern] [+ linenum] [file...]

Less pagination display file

The less tool is also a tool for pagination display of files or other output. It should be said that it is a tool for linux orthodox viewing the contents of files, which is extremely powerful. The usage of less is more flexible than that of more. In more, we have no way to turn to the front, we can only look back, but if we use less, we can use the function of [pageup] [pagedown] and other keys to go back and forth to browse the file, which is easier to view the contents of a file! In addition, less can have more search functions, not only to search down, but also to search up.

Command format:

Less [parameters] file

Tail displays the end of the file

Using the tail command, you can see the last few lines of the file, which is very effective for log files, because log files are often appended and new writes are at the end of the file.

Using the-f option of the tail command, you can easily check the changing log file. Tail-f filename will display the last content of the filename on the screen and not only refresh it, so that you can see the latest file contents.

Command format

Tail [necessary parameters] [Select parameters] [File]

Head displays file headers

Similar to the tail command, except that the head command displays a set of lines at the beginning of the file.

Command format:

Head [parameters]... [file].

Sort content sorting

A file contains many rows, and one of these rows often needs to be sorted, and the purpose of the sort command is to sort the data.

Command format:

Sort [parameters] [file]

Wc character statistics

The wc command can be used to count the number of characters, words, lines, and output statistical results in a specified file.

Command format:

Wc [options] file.

Uniq to view recurring lines

The uniq command can be used to display the number of repeated lines in a file, or to display lines that appear only once, and to show only repeated lines, and uniq deduplicates only two consecutive lines, so it is often used in conjunction with sort.

Command format:

Uniq [options] [parameters]

Curl URL access tool

If you want to access web documents through the HTTP protocol under the command line, you have to use a tool, which is curl, which supports HTTP,HTTPS,FTP,FTPS,Telnet and other protocols, and is often used to crawl web pages and monitor the status of WEB servers under the command line.

Command format:

Curl [option] [url]

Check the number of requests

For systems running online, they often encounter a variety of malicious attacks, of which the more common is HTTP flood, also known as CC attacks. How to quickly locate the attack and respond quickly has become a necessary skill for developers and operators. The quickest way to locate the problem is to log in to the appropriate application, view the access log, and find the appropriate attack source, such as the top 10 ip addresses:

Cat access.log | cut-F1-d "" | sort | uniq-c | sort-k 1-n-r | head-10

Url with the top 10 page views:

Cat access.log | cut-f4-d "" | sort | uniq-c | sort-k 1-n-r | head-10

View the most time-consuming pages

For developers, the response time of the page is of great concern, because it is directly related to whether the user can quickly see what he wants to see. As a result, developers often need to find pages that are slow to respond and optimize them:

Cat access.log | sort-k 2-n-r | head-10

Statistics of 404 pages

Sometimes you need to pay attention to the error code of the request. For example, if there are too many 404 requests, either a malicious attacker is scanning or there is a problem with the system. Similarly, the same is true for 500 requests. You can check the proportion of 404 requests with the following command:

Export total_line= `wc-l access.log | cut-F1-d "" `& & export not_found_line= `awk'$6 million not_found_line 404'{print $6} 'access.log | wc-l` & & expr $not_found_line\ * 100 / $total_line

More need to combine some commands of linux

At this point, I believe you have a deeper understanding of the "summary of log analysis commands necessary for Java development". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

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

Development

Wechat

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

12
Report