Created
January 20, 2013 13:37
-
-
Save maji-KY/4578679 to your computer and use it in GitHub Desktop.
LogWatch
java app
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
########################################################################## | |
# $Id: myApp,v 1.0 2012/12/23 20:35:04 maji-KY $ | |
########################################################################## | |
# | |
# | |
######################################################## | |
#use diagnostics; | |
#use strict; | |
#use warnings; | |
my %ErrorLog = (); | |
my %WarnLog = (); | |
my %InfoLog = (); | |
my %DebugLog = (); | |
my %TraceLog = (); | |
my @OtherList = (); | |
my $OtherCnt = 0; | |
while (my $ThisLine = <STDIN>) { | |
chomp($ThisLine); | |
next if ($ThisLine eq ''); | |
if ( $ThisLine =~ /INFO.*/o ) { | |
$InfoLog{$&}++; | |
} elsif ( $ThisLine =~ /WARN.*/o ) { | |
$WarnLog{$&}++; | |
} elsif ( $ThisLine =~ /ERROR.*/o ) { | |
$ErrorLog{$&}++; | |
} elsif ( $ThisLine =~ /DEBUG.*/o ) { | |
#$DebugLog{$&}++; | |
} elsif ( $ThisLine =~ /TRACE.*/o ) { | |
#$TraceLog{$&}++; | |
} elsif ( $OtherCnt < 200 ) { | |
# Report any unmatched entries... | |
push @OtherList,$ThisLine; | |
$OtherCnt++; | |
} | |
} | |
if (keys %ErrorLog) { | |
print "\nERROR:\n"; | |
foreach my $ThisOne (sort { $ErrorLog{$b} cmp $ErrorLog{$a} } keys %ErrorLog) { | |
print " " . $ThisOne ." : logged " . $ErrorLog{$ThisOne} . " time(s)\n"; | |
} | |
} | |
if (keys %WarnLog) { | |
print "\nWARN:\n"; | |
foreach my $ThisOne (sort { $WarnLog{$b} cmp $WarnLog{$a} } keys %WarnLog) { | |
print " " . $ThisOne ." : logged " . $WarnLog{$ThisOne} . " time(s)\n"; | |
} | |
} | |
if (keys %InfoLog) { | |
print "\nINFO:\n"; | |
foreach my $ThisOne (sort { $InfoLog{$b} cmp $InfoLog{$a} } keys %InfoLog) { | |
print " ". $ThisOne ." : logged " . $InfoLog{$ThisOne} . " time(s)\n"; | |
} | |
} | |
if ($#OtherList >= 0) { | |
print "\n**Unmatched Entries**\n"; | |
print @OtherList; | |
} | |
exit(0); | |
# vi: shiftwidth=3 tabstop=3 syntax=perl et | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
######################################################## | |
# Define log file group for myApp | |
######################################################## | |
# What actual file? Defaults to LogPath if not absolute path.... | |
LogFile = /var/log/test/test.log | |
# If the archives are searched, here is one or more line | |
# (optionally containing wildcards) that tell where they are... | |
#If you use a "-" in naming add that as well -mgt | |
Archive = /var/log/test/test.*.log | |
# Expand the repeats (actually just removes them now) | |
*ExpandRepeats | |
# Keep only the lines in the proper date range... | |
*applyeurodate | |
# vi: shiftwidth=3 tabstop=3 et |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
########################################################################### | |
# Configuration file for myApp filter | |
########################################################################### | |
Title = "myApp" | |
# Which logfile group... | |
LogFile = myapp | |
# vi: shiftwidth=3 tabstop=3 et |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment