linux 查看日志

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

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

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

1
2
[**@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条记录

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
[*@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 @   AlamZ  阅读(388)  评论(0编辑  收藏  举报
编辑推荐:
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
阅读排行:
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 上周热点回顾(3.3-3.9)
点击右上角即可分享
微信分享提示