程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> JAVA編程 >> 關於JAVA >> log4j perl 錯誤日志提取

log4j perl 錯誤日志提取

編輯:關於JAVA

日志

#!/bin/perl
use 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 [email protected] < _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

。。。。。。

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved