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

What is the method of linux large-scale service exception log retrieval

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

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

Today, I would like to share with you the relevant knowledge about the method of retrieving exception logs in linux large-scale services. The content is detailed and the logic is clear. I believe most people still know too much about this knowledge, so share this article for your reference. I hope you can get something after reading this article. Let's take a look at it.

Root@ bin # more check_log.sh # check the error log scripts in all specified log files in a directory

#! / usr/bin/env bash # is a declaration of shell

Base= "/ home/project" # defines a variable that specifies the directory where the log is scanned

While [[1]]; definition of infinite loop in do # shell

For name in `ls $base | grep-vE "default" `; # the for loop begins to traverse the files in the directory and filter out the default directory

Do # starts execution

Echo $base/$name # output directory path

If [[- d $base/$name]]; then # determines whether it is a directory or not

Result= `grep-C10 $base/$name/logs/catalina.out | grep-vE "DEBUG | skywalking | 10.8.0.37 grep 8800" | grep-C5-E "Exception | ERROR" `

# get the log of Exception | ERROR reported in the catalina.out file, and filter out the DEBUG | skywalking | 10.8.0.37 ERROR 8800

If [[- z "$result"]]; then # if determines if $result is empty

Continue; # continue

Fi # if Terminator

Echo-e "\ n\ 033 [31mfind Exception in $name\ 033 [0m\ n\ nExcpetion:\ n\ n$result" # A line of colored output indicates which directory has reported an error

Fi # if Terminator

Done # do Terminator

Echo-e "sleep 60 seconds\ n" # output take a minute break

Sleep 60s # wait one minute

Done # do Terminator

Shell is a program written in C language, which is a bridge for users to use Linux. Shell is both a command language and a programming language.

Shell is an application that provides an interface through which users access the services of the operating system kernel.

Shell script (shell script) is a scripting program written for shell.

These are all the contents of the article "what is the method of retrieving exception logs in linux large-scale service?" Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to the industry information channel.

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

Internet Technology

Wechat

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

12
Report