LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-05-2011, 02:58 PM   #1
mhylas
LQ Newbie
 
Registered: Oct 2011
Posts: 1

Rep: Reputation: Disabled
comparing log files for differences


Hello all,
My name is max and I am new to this forum. I am a beginner to Bash Scripting and been having a real problem trying to compare two log files. Long story short...
I have a known good wrapper.log file and I would like to have other new Wrapper.log files to compare next to it to see if any services did not start properly.
Normally I could just use the diff command or the cmp command in a script but this log file does not necessarily boot in the same lined order every time. So I think the only thing I am left with is using bash arrays? Could anyone point me in the right direction on how to start this project? MUCH MUCH thanks in advance.

This is a little snippit of the known good wrapper.log file below

STATUS | wrapper | 2011/09/28 19:45:00 | --> Wrapper Started as Daemon
STATUS | wrapper | 2011/09/28 19:45:00 | Java Service Wrapper Standard Edition 64-bit 3.4.1
STATUS | wrapper | 2011/09/28 19:45:00 | Copyright (C) 1999-2010 Tanuki Software, Ltd. All Rights Reserved.
STATUS | wrapper | 2011/09/28 19:45:00 | http://wrapper.tanukisoftware.org
STATUS | wrapper | 2011/09/28 19:45:00 | Licensed to TradeCard, Inc. for TradeCard Linux 64
STATUS | wrapper | 2011/09/28 19:45:00 |
INFO | wrapperp | 2011/09/28 19:45:00 | port 32000 already in use, using port 32001 instead.
STATUS | wrapper | 2011/09/28 19:45:00 | Launching a JVM...
INFO | jvm 1 | 2011/09/28 19:45:00 | Please use CMSClassUnloadingEnabled in place of CMSPermGenSweepingEnabled in the future
INFO | jvm 1 | 2011/09/28 19:45:01 | java version "1.6.0_22"
INFO | jvm 1 | 2011/09/28 19:45:01 | Java(TM) SE Runtime Environment (build 1.6.0_22-b04)
INFO | jvm 1 | 2011/09/28 19:45:01 | Java HotSpot(TM) 64-Bit Server VM (build 17.1-b03, mixed mode)

Last edited by mhylas; 10-05-2011 at 03:01 PM.
 
Old 10-05-2011, 03:07 PM   #2
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
Quote:
Originally Posted by mhylas View Post
... this log file does not necessarily boot in the same lined order every time. ...
So, you need to first order the lines (e.g. using service name as the field to be used for ordering), and then 'diff' the ordered lines - say, saving them first in files.
 
Old 10-05-2011, 03:08 PM   #3
eSelix
Senior Member
 
Registered: Oct 2009
Location: Wroclaw, Poland
Distribution: Arch, Kubuntu
Posts: 1,281

Rep: Reputation: 320Reputation: 320Reputation: 320Reputation: 320
If you no need orginal order of lines in theses log files, maybe use "sort" to obtain differences. Also, for later looking these lines in orginal log, you can add column with orginal line number, for ex. "grep" can do it.
 
Old 10-06-2011, 11:35 AM   #4
ghborrmann
Member
 
Registered: May 2004
Location: Louisville KY
Distribution: Fedora 25
Posts: 32

Rep: Reputation: 0
I, too, am looking for a solution to the problem of comparing log files. The previous replies have focused on the problem that the lines may not always be in the same order. However, the main problem is that the time stamps are always different. Just being able to execute a "diff" while ignoring the different time stamps would help. Does anyone have any suggestions to achieve that?
 
Old 10-06-2011, 11:41 AM   #5
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
Quote:
Originally Posted by ghborrmann View Post
I, too, am looking for a solution to the problem of comparing log files. The previous replies have focused on the problem that the lines may not always be in the same order. However, the main problem is that the time stamps are always different. Just being able to execute a "diff" while ignoring the different time stamps would help. Does anyone have any suggestions to achieve that?
Write a parser, then compare, using a custom function, the resulting from parser data structures of the two files to be compared. The custom function can ignore, for example, timestamps.

The proposed solution is ages old and is widely used.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
convert screen.log and putty.log files into linux readable files aksharb Linux - Software 1 03-20-2011 07:16 AM
comparing files newbiesforever Linux - Software 3 07-07-2010 03:20 PM
Comparing files and copying differences gregmcc Linux - Newbie 7 04-23-2009 12:54 PM
Comparing 2 Files xianzai Programming 2 05-23-2004 11:50 AM
Can log files be time stamped? (such as FTP login and transfer log files) bripage Linux - Networking 6 08-08-2002 10:55 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:23 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration