Log4j perl error Log extraction

Source: Internet
Author: User
Tags tomcat log4j

Log

#!/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 {$}) {
       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;

Results:

>>>>>>>/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

。。。。。。

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.