Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Go to start of metadata

Apache Tomcat is an implementation of the Java Servlet and JavaServer Pages technologies. It is used as the servlet container for

...

XperienCentral and therefore catches all log messages

...

that XperienCentral generates. How and where the messages are being logged by Tomcat is determined by

...

a system administrator. By default, the main log file is written to

...

<Tomcat dir>/logs/catalina.out

...

.

However, it is often the case that the log files are being rotated in order to prevent them from getting too big to handle.

Analysis

Log files contain the heartbeat of your

...

XperienCentral installation

...

therefore keeping an eye on them is a wise idea.

...

Below is a

...

Linux script to help you analyze the

...

catalina.out

...

file. It organizes the messages in the logfile and sorts them according to the number of occurrences in the logfile, meaning the most recurring message will end up on top.




Code Block
themeEclipse
#!/bin/sh

...

 


# File:

...

         prunelog9.sh

...


# Version:

...

      1.2

...


#

...

 Author:       author
# Created:      2009-02-27

...


# Copyright:

...

    copyright (c) 2009 GX, http://www.gxwebmanager.com/

...

#               This program is free software: you can redistribute it and/or modify
#               it. This program is distributed in the hope that it will be useful,
#               but WITHOUT ANY WARRANTY; without even the implied warranty of
#               MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
# Description:  This script will take a Tomcat catalina.out logfile for WebManager 9
#               and prune it to unique error messages while sorting it on the number
#               of occurrences. The result is a sorted list of most occurring errors
#               on a WebManager 9 installation.
#
# Usage:
#               prunelog9.sh [ -g ] logfile
#
# Arguments:    -g (optional) Generalize error messages
#
# History:
#               0.9   OMG! Perl and shell! It's been a while!
#               1.0   Works like a charm.
#               1.1   Removing stacktraces for better totals
#               1.2   Bugfix: Day-of-month can be one or two digits.
#
 
if [ $# -eq 1 ]; then
    LOGFILE=$1

...


#               This program is free software: you can redistribute it and/or modify
#               it. This program is distributed in the hope that it will be useful,
#               but WITHOUT ANY WARRANTY; without even the implied warranty of
#               MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
# Description:  This script will take a Tomcat catalina.out logfile for WebManager 9
#               and prune it to unique error messages while sorting it on the number
#               of occurrences. The result is a sorted list of most occurring errors
#               on a WebManager 9 installation.
#
# Usage:
#               prunelog9.sh [ -g ] logfile
#
# Arguments:    -g (optional) Generalize error messages
#
# History:
#               0.9   OMG! Perl and shell! It's been a while!
#               1.0   Works like a charm.
#               1.1   Removing stacktraces for better totals
#               1.2   Bugfix: Day-of-month can be one or two digits.
#

if [ $# -eq 1 ]; then
    LOGFILE=$1
    PERLFILTER='$OUTPUT_AUTOFLUSH = 1;my $outline = "";while (my $line = <STDIN>) { chomp $line; if ($line =~ /^\w{3} \d+, \d{4} \d+:\d+:\d+ \w{2} (.*)$/) { my $leftover = $1; print $outline . "\n"; $outline = $leftover; } else { if (!($line =~ /^\tat /)) { $outline .= " ##### " . $line; } } }'

...

else

...


else
    if [[ "$1" == "-g" ]];

...

        LOGFILE=$2

...

 then
        LOGFILE=$2 PERLFILTER='$OUTPUT_AUTOFLUSH = 1;my $outline = "";while (my $line = <STDIN>) { chomp $line; if ($line =~ /^\w{3} \d+, \d{4} \d+:\d+:\d+ \w{2} (.*)$/) { my $leftover = $1; $outline =~ s/\d{5,9}/xxxxxx/g; print $outline . "\n"; $outline = $leftover; } else { if (!($line =~ /^\tat /)) { $outline .= " ##### " . $line; } } }'

...

    else

...


    else
        echo "Usage: $0 [ -g ] logfile";

...

        exit
    fi
fi
 
if [[ ! -f $LOGFILE ]]; then
    echo "No such file: $LOGFILE"
    echo "Usage: $0 [ -g ] logfile";
    exit
fi
 
# Chain the filters together
/bin/cat $LOGFILE | \

        exit
    fi
fi

if [[ ! -f $LOGFILE ]]; then
    echo "No such file: $LOGFILE"
    echo "Usage: $0 [ -g ] logfile";
    exit
fi

# Chain the filters together
/bin/cat $LOGFILE | \
/usr/bin/perl -e "$PERLFILTER" | \

...


/bin/sort | \

...


/usr/bin/uniq -c | \

...


/bin/sort -nr | \

...


/bin/sed -e "s/ ##### /\n/g"

...


How to make the code above work:

  • Copy and paste the code above to a file named "prunelog9.sh"
  • Make the file executable: "chmod +x prunelog9.sh"
  • Download or copy the logfile you want to analyze, e.g. "catalina.out"
  • Usage examples:

...


author:~> ./prunelog.sh -g catalina.out
     41 nl.gx.webmanager.cms.core.implementation.PresentableImpl render
SEVERE: presentation is null for baseobject with id xxxxxx
     37 nl.gx.siteworks.core.SiteWorksSession getObject
WARNING: Unable to find node with id xxxxxx
...

 

...

author:~> ./prunelog.sh catalina.out
&nbsp;&nbsp;&nbsp;&nbsp; 14 nl.gx.webmanager.cms.core.implementation.PresentableImpl render
SEVERE: presentation is null for baseobject with id 475486
&nbsp;&nbsp;&nbsp;&nbsp; 10 nl.gx.webmanager.services.sessionmanager.impl.WebManagerAPI getWrapper
SEVERE: Unable to create wrapper for id '32314' of class 'interface nl.gx.webmanager.cms.mediarepository.MediaItemVersion'.
...