Here is a shell script to examine the logs for exceptions. I run mine every
five minutes.
#!/bin/sh
#######################################################################
# Tomcat Exception Log script.
#
# This script checks your tomcat log files for any lines containing
# the word exception. If it finds some it mails a specified person
#
# A history mechanism is used so that you only receive messages when
# new exceptions are found.
#
#######################################################################
LOGDIR=/var/www/tomcat/logs
[EMAIL PROTECTED]
DT=`date +%Y-%m-%d`
logcheck () {
MARKER=$1
LOGFILE=$2
TMPFILE=exCheck$$.tmp
if [ ! -f $LOGFILE ]; then
return
fi
if [ ! -e $MARKER ]; then
touch $MARKER
fi
grep -ie exception $LOGFILE > $TMPFILE
if [ -s $TMPFILE ]; then
#
# file exists and is not empty
#
OLDSIZE=`wc -c $MARKER`
OLDSIZE=`echo $OLDSIZE | cut -f1 --delimiter=" "`
NEWSIZE=`wc -c $TMPFILE`
NEWSIZE=`echo $NEWSIZE | cut -f1 --delimiter=" "`
if [ "$OLDSIZE" != "$NEWSIZE" ]; then
mail -s "Tomcat Exception $LOGFILE" $MAILDEST < $TMPFILE
mv -f $TMPFILE $MARKER
else
rm -f $TMPFILE
fi
else
#
# file doesnt exist or is empty
#
mv -f $TMPFILE $MARKER
fi
}
cd $LOGDIR
logcheck ".catalina.out" "catalina.out"
OTHERFILES=`ls *$DT.txt 2> /dev/null`
for FILE in $OTHERFILES; do
MARKERFILE=`echo $FILE | cut -f1 --delimiter="."`
logcheck ".$MARKERFILE" $FILE
done
-----Original Message-----
From: Chris Gokey [mailto:[EMAIL PROTECTED]
Sent: Tuesday, March 25, 2003 7:48 PM
To: Tomcat Users List
Subject: Re: SMTP Logger
Hi everyone,
Back to this again.. Any help would be very appreciated.
I'd created a custom logger that will email errors rather than log them
to a file system.
Unfortunately, if I add another <Logger className="..."> declaration to
server.xml, it will not use the existing Logger (FileLogger). How can I
make it use both?
Optionally, I thought of extends the FileLogger, but it is declared
final, so this won't work.
How should I approach this? Or maybe there is some class already part
of Tomcat that can do what I'm looking for?
I'm using Tomcat 4.03 under Redhat 8.
Thanks in advance.
Chris
On Sat, 2003-03-08 at 21:17, Chris Gokey wrote:
> Is there alternatives to the FileLogger class?
> <!-- Global logger unless overridden at lower levels -->
> <Logger className="org.apache.catalina.logger.FileLogger"
> prefix="catalina_log." suffix=".txt"
> timestamp="true"/>
>
> I'd like intercept any errors in Tomcat and mail these errors to a
> particular person.
>
> If not, can I add another Logger by specifying an entry like the above
> in the server.xml and creating my custom Logger class? Is that all
> that is necessary?
>
> Thanks,
> Chris
--
Christopher D. Gokey, SSAI, NASA/GCMD
18 Martin Road, Shelburne Falls, MA 01370
Phone: Voice (413) 625-8129 / FAX 208-248-9055
[EMAIL PROTECTED]
AOL: chrisgokey
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]