linux 查看日志

1.需求:查看日志是否发送邮件成功

2.数据库中查到相关的id号

代码:cat -n test.log |grep "地形"  得到关键日志的行号

[**@app3.*s:/app/local/jboss/tw/log]$ cat -n server.log|grep '779571'
1933	2017-05-25 00:23:09,245 DEBUG [com.ticketweb.report.service.ReportManagementBean] Current scheduled report's saved report id: 779571

得到关键日志的行号,此时如果我想

查看这个关键字前10行和后10行的日志: cat -n server.log |tail -n +1933 |head -n 20

tail -n +1933 表示查询1933 行之后的日志

head -n 20 则表示在前面的查询结果里再查前20条记录

 

[*@app3.*cs:/app/local/jboss/tw/log]$ cat -n server.log|tail -n +1923|head -n 20
  1923	2017-05-25 00:23:09,242 DEBUG [com.*.ReportManagementBean] Calling MailService.sendEmail(message) to send Email for scheduledReport id:602541
  1924	2017-05-25 00:23:09,242 DEBUG [com.*.ReportManagementBean] To:tcttemplate@gmail.com
  1925	2017-05-25 00:23:09,242 DEBUG [com.*.ReportManagementBean] CC:null
  1926	2017-05-25 00:23:09,242 DEBUG [com.*.ReportManagementBean] Subject:alam test 3 uk
  1927	2017-05-25 00:23:09,242 DEBUG [com.*.ReportManagementBean] Report sent by MailService.sendEmail(message).Please see attached for the reports.
  1928	2017-05-25 00:23:09,244 DEBUG [com.*.schedulable.ReportEmailSendHelper] Email sent on: 2017-05-25 00:23:09.244
  1929	2017-05-25 00:23:09,244 DEBUG [com.*.schedulable.ReportEmailSendHelper] Emailing report id: 602611 , name: alam master uk 11
  1930	2017-05-25 00:23:09,245 DEBUG [com.*.ReportEmailSendHelper] Emailing starts on2017-05-25 00:23:09.244
  1931	2017-05-25 00:23:09,245 DEBUG [com.*.ReportManagementBean] Current scheduled report id: 602611
  1932	2017-05-25 00:23:09,245 DEBUG [com.*.ReportManagementBean] Current scheduled report's orgId: 4
  1933	2017-05-25 00:23:09,245 DEBUG [com.*.ReportManagementBean] Current scheduled report's saved report id: 779571
  1934	2017-05-25 00:23:09,245 DEBUG [com.*.ReportManagementBean] Current scheduled report's saved report's eid: null
  1935	2017-05-25 00:23:09,246 DEBUG [com.*.ReportManagementBean] Generating the TemplateReportConfig by calling ReportConfigFactory.getConfig(...)
  1936	2017-05-25 00:23:09,270 DEBUG [com.*.ReportManagementBean] Initializing the TemplateReportConfig object...
  1937	2017-05-25 00:23:09,270 DEBUG [com.*.ReportManagementBean] The value of txDate_toDate has been cut off to the prev day mid night:2017-05-24+23:59:59
  1938	2017-05-25 00:23:09,270 DEBUG [com.*.ReportManagementBean] The value of txDate_toDate has been cut off to the prev day mid night:2017-05-24+23:59:59
  1939	2017-05-25 00:23:09,270 DEBUG [com.*.ReportManagementBean] The value of txDate_toDate has been cut off to the prev day mid night:2017-05-24+23:59:59
  1940	2017-05-25 00:23:09,270 DEBUG [com.*.ReportManagementBean] saved report param name is: country saved report param value is GB
  1941	2017-05-25 00:23:09,270 DEBUG [com.*.ReportManagementBean] The value of txDate_toDate has been cut off to the prev day mid night:2017-05-24+23:59:59
  1942	2017-05-25 00:23:09,270 DEBUG [com.*.ReportManagementBean] Initialized the TemplateReportConfig object successfully.

 

  

 

posted @ 2017-05-25 15:53  AlamZ  阅读(387)  评论(0编辑  收藏  举报