log4j perl 錯誤記錄檔提取

來源:互聯網
上載者:User

日誌

#!/bin/perluse Encode ;open(NOTESFILES,$ARGV[0]);my %errorMeganotes;print ">>>>>>>>>>>>>>",$ARGV[0],"<<<<<<<<<<\n";while (<NOTESFILES>) {  if( $_=~/^(\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}:\d{2})\s+ERROR\s+(.*)\s/g ){     if($errorMeganotes{$2}){       push @{$errorMeganotes{$2}},$1;     }else{       $errorMeganotes{$2}=[$1];     }  }}for(keys %errorMeganotes){  my $tmp_keys=$_;  my @tmp_array= @{$errorMeganotes{$tmp_keys}};  print "error number :>>",scalar(@tmp_array),"<<\n",encode("GBK",decode("UTF-8",$tmp_keys)),"\n",join(",\t",@tmp_array),"\n\n\n";}

sh

#!/bin/sh
nowDate=$(date-d'-1day'+%Y-%m-%d);
echo$nowDate
perl/data/apps/shell/meganotesErrorLog.pl/data/apps/meganotes/tomcat/l ogs/app/app.log.$nowDate> _tmp_$nowDate;
perl/data/apps/shell/meganotesErrorLog.pl/data/apps/schedule/tomcat/lo gs/app/app.log.$nowDate >>_tmp_$nowDate;
mail-s$nowDate-ERROR-log my@mail.com < _tmp_$nowDate;
rm_tmp_$nowDate;

結果:

>>>>>>>/data/apps/meganotes/tomcat/logs/app/ap p.log.2009-02-18<<<<<<<<<

error number :>>2<<

MusicActionOpLogProxy:142 - music.popularTime=[Invalid field value for field "music.popularTime".]

2009-02-18 15:53:54,  2009-02-18 16:00:12

。。。。。。

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.