Web based LOG PARSING Software needed

I have an application that creates a log file.
The log file contains entries as follows :

What I need is a web based application that can do the following I need to enter a number for example XXXXXXX and it checks the log file for the occurence of that number and displays it starting from <xmlA> that precedes it till </xmlA> that follows it.

Can anyone tell me about such a log parsing software for linux or do I have to write my own scripts and php web page ?
LVL 19
http:// thevpn.guruAsked:
Who is Participating?
crustymonkeyConnect With a Mentor Commented:
Here is a quick script to get you started:

/*----------- CODE -----------------*/

$file = '/path/to/logfile';
$file = 'logfile';

function form () {
<h3>Number Search</h3>
    <form name="search" method="post" action="<?=$_SERVER['PHP_SELF']?>">
    Number: <input type="text" name="number" size="15" />
    <input type="submit" />

function processForm ($file , $regex) {
    $fh = fopen($file , 'r');
    $contents = fread($fh , filesize($file));
    $ms = array();
    preg_match_all($regex , $contents , $ms);
    foreach ($ms[0] as $m) {
        print(htmlspecialchars($m) . "\n");

    <title>Number Search</title>

if ($_POST) {
    $search = $_POST['number'];
    $regex = "/<xmlA>[^<]*${search}[^<]*<\/xmlA>/ims";
    processForm($file , $regex);
else {

/*-------------- END CODE ----------------*/

This is a starting point for you.  One thing to note is that if you want to capture a very specific sequence and you know that there is whitespace on either side of it, you will want to modify the regex to be more like this:

$regex = "/<xmlA>[^<]*\b${search}\b[^<]*<\/xmlA>/ims";

That will make sure you match the EXACT string separated by a word boundary on either side.
I think this is overkill for your application, but check out Splunk (http://www.splunk.com/).  This is an everything and the kitchen sink type of app, but it really rocks for log consolidation.

Really though, a quick PHP page would probably suit you much better for this specific an application.  If you need help with writing that, let me know.
http:// thevpn.guruAuthor Commented:
Hmm...I mean u are right..it might be easier to do it..what do have in mind.?
3 quick questions.  How big does the log file get?  Is the log file line based?  Meaning, are there entries like so:

<xmlA>blah blah</xmlA>
<xmlA>blah blah blah</xmlA>

or do they look more like:

<xmlA>blah blah
stuff after a line break
more blah</xmlA>

And lastly, is it a valid XML document?
http:// thevpn.guruAuthor Commented:
no it is not a valid xml document...and it looks more like

<xmlA>blah blah
stuff after a line break
more blah</xmlA>

I can control the size of the log file as needed
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.