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.(这一模式的意思是一个可变长字符串的列表。通过新的行分开,列表里边的任何一个都可以去被扩展)

动态查看日志的命令

tail -f xxx.log

然后发现该命令打印日志报错的信息查看起来不是很方便,很难去具体排查出错的地方可通过输入以下的命令:

grep xxx.log -e ERROR ##xxx.log为日志的文件名 ERROR为日志中的出现ERROR的字段

这样就会在linux中显示日志具体的报错时间和具体报错的内容。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值