linux查看錯誤日誌

將jar包部署到服務器,程序在跑了一段時間後發現日誌報錯。然後想要找到具體報錯的地方。

先查看日誌,然後用管道通道符查找日誌中有error的字段。

cat xxx.log | grep ERROR ## | 爲管道符 

grep:

命名:

grep,egrep,fgrep -print line mathing a pattern (打印匹配行的一種方法)

描述:

searches the named input files for lines containing a match to the given pattern.by default,grep prints the matching lines.(與輸入文件的行中包含的某一字段進行匹配,grep默認打印的是匹配行的內容)

in addition,two variant programs egrep and fgrep are available.egrep is the same as grep -E.fgrep is the same as grep -F.Direct invocation as either egrep or fgrep is deprecated.but is provided to allow historical applications that rely on then to run unmodified.(另外,兩個變量egrep和fgrep是可獲得的,egrep等同於grep -E,fgrep等同於grep-F。直接調用egrep和fgrep是過時的,但是允許依賴歷史性的應用程序不加修改地執行)

可選項:

-E  --extended-regexp 

Interpret pattern as an extended regular expression.(這一模式意思是一個擴展的正則表達式)

-F --fixed-strings, --fixed-regexp

Interpret pattern as a list of fixed strings,seperated by newlines.any of which is to be extended.(這一模式的意思是一個可變長字符串的列表。通過新的行分開,列表裏邊的任何一個都可以去被擴展)

然後發現該命令並沒有打印日誌報錯的時間,很難去具體排查出錯的地方然後通過輸入以下的命令:

grep xxx.log -e ERROR ##xxx.log爲日誌的文件名 ERROR爲日誌中的出現ERROR的字段

這樣就會在linux中顯示日誌具體的報錯時間和具體報錯的內容。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章